Example when 'declare class before use' is necessary

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@203386 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Jakub Vrana 2005-12-21 15:04:47 +00:00
parent 9af45fa3ce
commit 49d06d7d6c

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.44 $ -->
<!-- $Revision: 1.45 $ -->
<appendix id="migration5">
<title>Migrating from PHP 4 to PHP 5</title>
@ -96,8 +96,9 @@
<listitem>
<simpara>
In some cases classes must be declared before used. It only happens
only if some of the new features of PHP 5 are used. Otherwise the
behaviour is the old.
only if some of the new features of PHP 5 (such as <link
linkend="language.oop5.interfaces">interfaces</link>) are used.
Otherwise the behaviour is the old.
</simpara>
</listitem>
<listitem>
@ -127,11 +128,10 @@
</listitem>
<listitem>
<simpara>
If there are functions defined in the included file, they will be defined
in the main file, whether they are before or after the
<function>return</function> instruction. If the file is included twice,
PHP 5 issues fatal error because functions were already declared, while
PHP 4 doesn't complain about it.
If there are functions defined in the included file, they can be used in the
main file independent if they are before <function>return</function> or after.
If the file is included twice, PHP 5 issues fatal error because functions
were already declared, while PHP 4 doesn't complain about it.
It is recommended to use <function>include_once</function> instead of
checking if the file was already included and conditionally return inside
the included file.