mardi 2 juin 2015

PHP - include() in IF statement

I have a simple PHP question. If I use the include() function in an IF statement like this:

<?php

if ($a==1) {
echo "hello!";
}
else {
include("myfile.php");
}

?>

If $a = 1 then it should print "hello" and it should not include "myfile.php". In this scenario I wanna ask:

Even if the ELSE statement is not true, is myfile.php loaded?

I obviously know that it doesn't get executed but is the file loaded?

I mean, if myfile.php is 300 KB, the page size will be 300 KB even if $a = 1 and include("myfile.php"); doesn't get executed?

Does this same thing apply also to require() and include_once() and require_once?

Thank you

Aucun commentaire:

Enregistrer un commentaire