-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|350|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Blogs Home -> Blogs


 
Jayenkai
Created : 04 November 2007
 

PHP's Include rules

Ahaa, now I can make my script a bit neater!

I stumbled across something rather interesting, this morning.
Well, I say stumbled. I kinda went looking for it, 'cos I thought it'd be useful if it worked.
I created 2 test files.
Test1.php, and Test2.php

Test 1 contains the following code.


...and Test 2


Note the "error" there. If you run test2.php, an error occurs.
If you run test1.php, the switch/case does not activate the main bit of code, and since the include is inside that bit of code, it doesn't ever actually get included!
Before, I'd thought that php would work much the same as Blitz, whereby wherever you stick an Include, it would automatically include the file requested. I guess not. Probably because php is an interpreted language, so it can deal with adding bits in as it goes, whereas Blitz needs to compile everything at the start.

And I'm happy about this, because it now means I can strip whole chunks of the site out of the main .php file, and start making many more includes than before.
Jay is happy!

 

Comments