|
Parser behaviorParsing and execution are now two completely separated steps, no execution of a files code will happen until the complete file and everything it requires has completely and successfully been parsed.
One of the new requirements introduced with this split is that
required and included files now have to be syntactically
complete. You can no longer spread the different controlling parts
of a control structure across file boundaries. That is you cannot
start a
It is still perfectly legal to include additional code within loops
or other control structures, only the controlling keywords and
corresponding curly braces This should not harm too much as spreading code like this should be considered as very bad style anyway. Another thing no longer possible, though rarely seen in PHP 3 code is returning values from a required file. Returning a value from an included file is still possible. Code Examples / Notes » migration4.parseralan
Although I reported this in the early days of php4 release as a migration problem, it has yet to appear in the manual. So add this note to clarify things for newcomers to php4 conversions. An apparent parser change occurred between php3 and php4 to the function unset(). There are now lots of maybe confusing comments about this in the manual under this functions page which you should read. To clarify an important difference which I spotted, the behaviour of unset() when used within a function on static or global variables gives quite different effects. In php3 the values of such variables were simply reset whereas now the variable is completely removed and any subsequent reference to the same variable name results in a completely new variable being defined - ie. a local function variable is created. Some misunderstandings about the original php3 function are obvious amongst non-php authors. Quite possibly the present php4 interpretation is what was originally intended in php3, but since it was not implemented in this way can give rise to shocks when the same scripts are run under php4. e.g. function foo() { global $bar; // at this point $bar is global $bar="assign this string"; unset($bar); // at this point $bar is local $bar="overwrite string"; // so this assignment does not affect the global} foo(); echo $bar; Under php3 you would get "overwrite string", but under php4 "assign this string". A similar difference occurs using unset to wipe out an array. The variable is no longer an array, and the memory used by the array is not released for re-use. You are advised to replace any uses of: unset($arr); by instead $arr=array(); |