|
Posted by Kimmo Laine on 02/01/07 13:43
"Captain Paralytic" <paul_lautman@yahoo.com> wrote in message
news:1170328792.349222.6920@l53g2000cwa.googlegroups.com...
> On 1 Feb, 11:14, "P Pulkkinen"
> <perttu.POISTATAMA.pulkki...@POISTATAMA.elisanet.fi> wrote:
>> Dear A Kaufman, I can't IMAGINE what you mean by this post in one
>> previous
>> thread.
>>
>> =================================================
>> "An include/require will be included no matter what.
>>
>> For example:
>> <?php
>> if(TRUE){
>> include "myfile.php";} else {
>>
>> include "yourfile.php";}
>>
>> ?>
>>
>> In the above example - BOTH files will be included no matter what."
>> =================================================
>>
>> This is NOT OF COURSE the case!
>>
>> http://perttu.finote.com/muuta/test.php
>>
>> Here I have in same folder files myfile.php and yourfile.php, other one
>> echoing
>> This text comes from file myfile.php
>> and other one echoing
>> This text comes from file yourfile.php
>>
>> but OF COURSE test.php prints only "This text comes from file
>> myfile.php"
>
> He did not say that the contents of both files would be executed, he
> said that both files would be included. The if/then/else statement
> will ensure that the contents of yourfile.php do not get executed,
> however they WILL be included.
A proper way to test it might be including a HUGE (like Donald Trump Huge) a
file and see if there's a performance peak... like this:
<?php
$started = time();
if(FALSE){
require('my_huge_1Gb_bogus_file.php');
}
echo 'elapsed = '.(time()-$started);
?>
I'm thinking if elapsed time jumps thru the roof, then the file was accessed
and read into memory, but not executed thou. my_huge_1Gb_bogus_file.php
could just be <?php /* LOL OMG THIS IS A TEST LOL OMG THIS IS A TEST LOL OMG
THIS IS A TEST .... */ ?> repeated a zillion times so that the file size
would actually become gigantic.
Another thing is that if you use require and a non-existing file, php
doesn't throw an error if the require statement is unreachable, like behind
if(FALSE), only when the file really is included in the code.
--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net | rot13(xvzzb@bhgbyrzcv.arg)
Navigation:
[Reply to this message]
|