From 6441e07fbec599e76d2514b806a6f1dff4961bbd Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 27 Jul 2004 21:17:22 +0000 Subject: [PATCH] Functions are defined even if they are after return statement in included file (bug #26032) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@164493 c90b9560-bf6c-de11-be94-00142212c4b1 --- appendices/migration5.xml | 13 ++++++++++++- language/control-structures.xml | 11 ++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/appendices/migration5.xml b/appendices/migration5.xml index 01b4640966..a9d80a0dd2 100755 --- a/appendices/migration5.xml +++ b/appendices/migration5.xml @@ -1,5 +1,5 @@ - + Migrating from PHP 4 to PHP 5 @@ -107,6 +107,17 @@ -1. + + + If there are functions defined in the included file, they can be used in the + main file independent if they are before return 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 include_once instead of + checking if the file was already included and conditionally return inside + the included file. + + include_once and require_once diff --git a/language/control-structures.xml b/language/control-structures.xml index f2aaf47aed..2de073da1f 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -1500,6 +1500,15 @@ echo $bar; // prints 1 If the file can't be included, &false; is returned and E_WARNING is issued. + + If there are functions defined in the included file, they can be used in the + main file independent if they are before return 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 include_once instead of + checking if the file was already included and conditionally return inside + the included file. + A few other ways to "include" files into variables are with fopen, file or by using