I'm a developer who has recently seen the light and have made a switch from coldfusion to php. There is one thing I'm missing from coldfusion and that is the application.cfm. For those who don't know what that does, coldfusion automatically includes the application.cfm (which usually contains global variables you need) in all it's files from that directory level down. Now if a application.cfm exists in the root your file is currently in and again in the directory above, it will only include the applcation.cfm in the directory level you are at. It never goes to a lower directory, just above if it doesn't exist at that level. I created something in php to imitate that function but I can't believe this is the best way to do it in php. What I did was set in the php.ini the auto_prepend_file = "c:\inetpub\wwwroot\auto_prepend.php". Then I created a file ( I took some of the code from someone else's example a while back in here but wasn't really doing what cf would do so I modified it) called auto_prepend.php in my webserver root with the following code...
$dirs = split("/", $SERVER['PHP_SELF']);
$dirPiece = "";
for( $i=0; $i < count($dirs); $i++ ) {
$file = $dirPiece . "application.php";
if( @file_exists($file) ) {
include($file);
break;
}
$dirPiece = "../" . $_dirPiece;
}
This seems to work great, just afraid of performance by doing this. Any opinions or suggestions for a PHP newbie? Thanks!