RE: [PHP] PHP is a Bloated Kludge, discuss!
| From: | Maxim Maletsky \(PHPBeginner.com\) | Date: | Fri, 05 Oct 2001 01:32:51 +0000 |
| Subject: | RE: [PHP] PHP is a Bloated Kludge, discuss! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70002@lists.php.net to get a copy of this message | ||
> > PHP on the other hand seems to load in ALL the code that
> MAY be run.
> > i.e. an include brings things in which are inside an if,
> even if the
> > if equates to false.
>
> A quick check in the manual, it states that:
>
> "Unlike include(), require() will always read in the target
> file, even if the line it's on never executes. If you want to
> conditionally include a file, use include(). The conditional
> statement won't affect the 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. "
> http://www.php.net/manual/en/function.require.php
> and
> http://www.php.net/manual/en/function.require-once.php
>
>
> So to do what you said i.e. conditionally load the
> function/files that you want then you should use include().
> http://www.php.net/manual/en/function.include.php
> and
> http://www.php.net/manual/en/function.include-once.php
>
> So I don't buy this agument.
This is outdated. Look int othe archives - I had this discussion with
Zeev close to a year ago - since PHP 4.0.(something) require and include
behaves in the exactly same way.
Test it yourself on the latest release of PHP:
require.test.php
----
<?
echo 'included?';
if($go)
require 'require.error.test';
?>
----
require.error.test
----
<?
echo '<H1>yup!</H1>';
parse error;
?>
----
Access it with:
1. require.test.php?go=e
And then try it with:
2. require.test.php
What do you buy now?
Maxim Maletsky
www.PHPBeginner.com