PHP keeps its symbol tables at runtime, so a variable's name can be recovered — but only from the right scope, and only by giving it a unique value first. This post derives get_variable_name(&$var, $scope) step by step.
with 0 CommentI've been busy developing Yaf (Yet another Framework), a Zend Framework–style PHP framework written as a PHP extension. The goal: a real-world showcase of the Zend API (classes, interfaces, inheritance, autoloading) that also solves the framework performance problem.
with 0 CommentHow does PHP's exception mechanism actually work, and what is the ZEND_HANDLE_EXCEPTION opcode at the end of every independently executable op_array for? A walk through what happens when an exception is thrown, how try/catch and user_exception_handler fit in, and why that opcode was gone from PHP 5.3 on.
with 0 CommentSomeone asked me today, saying he'd seen a PHPer talking about an unless statement. I was quite puzzled, until I learned that a well-known PHP guru abroad had hacked the PHP source himself and added an unless statement.
Interesting. So today I'll show you how to add an unless statement to our own PHP.
Before PHP 5.3 the only ways to pass a callback were a function name string or the return value of create_function. This post walks through how create_function works internally, then looks at how PHP 5.3's Closure objects bind external variables as static properties.
with 0 CommentToday, Tank asked about this regex:
/<script>.*?</script>/is
When the string to be matched is longer than 100014, it will not produce the correct result:
$reg = "/<script>.*?</script>/is"; $str = "<script>********</script>"; //length greater than 100014 $ret = preg_replace($reg, "", $str); //returns NULL
Does a regex impose a length limit on the string it matches?
with 0 Comment