Forum Moderators: coopster
The paragraph is taken out of his "PHP for the world wide web" book.
I used the following code to do a testing
<?PHP
$a = 1;
if($a == 2) {
require("header.php");
}
?>
and based on what he said, header.php would show up. But nope, didn't work like that.
What do you think?
Note: Prior to PHP 4.0.2, the following applies: require() will always attempt to read the target file, even if the line it's on never executes. The conditional statement won't affect require(). However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed. Similarly, looping structures do not affect the behaviour of require(). Although the code contained in the target file is still subject to the loop, the require() itself happens only once.
Now that I've read the above paragraph a couple of times, I think I am confused.
However, if the line on which the require() occurs is not executed, neither will any of the code in the target file be executed.
So prior to 4.0.2, php will attempt to read the target file in require(), but wouldn't actually execute it? hmm..isn't that almost useless? it reads the file but not executing it? Isn't that the same as not reading the file in the first place?