note 100737 added to function.include-once
| From: | gonzalezea at gmail dot com | Date: | Wed, 03 Nov 2010 17:35:24 +0000 |
| Subject: | note 100737 added to function.include-once | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-173719@lists.php.net to get a copy of this message | ||
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
----
Server IP: 200.6.154.201
Probable Submitter: 201.242.161.67
----
Manual Page -- http://www.php.net/manual/en/function.include-once.php
Edit -- https://master.php.net/note/edit/100737
Del: integrated -- https://master.php.net/note/delete/100737/integrated
Del: useless -- https://master.php.net/note/delete/100737/useless
Del: bad code -- https://master.php.net/note/delete/100737/bad+code
Del: spam -- https://master.php.net/note/delete/100737/spam
Del: non-english -- https://master.php.net/note/delete/100737/non-english
Del: in docs -- https://master.php.net/note/delete/100737/in+docs
Del: other reasons-- https://master.php.net/note/delete/100737
Reject -- https://master.php.net/note/reject/100737
Search -- https://master.php.net/manage/user-notes.php