note 100737 deleted from function.include-once by thiago

From: Date: Wed, 03 Nov 2010 17:38:14 +0000
Subject: note 100737 deleted from function.include-once by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173720@lists.php.net to get a copy of this message
Note Submitter: gonzalezea at gmail dot com ---- Be aware that variable expansions in include file occurs only once (same behaviour in require_once ), for example: # test.inc <?php $b = $a; ?> # test.php <?php $a = 1; include_once('test.inc'); echo "b value is $b<br>"; $a = 5; include_once('test.inc'); echo "b new value is $b<br>"; ?> // output is b value is 1 b new value is 1 My personal policy is do not include executable code in include_once (just classes, function,etc), unless there are variables you don't expect to change over script lifetime i.e. config vars or defines

« previous php.notes (#173720) next »