note 56511 deleted from function.include by mazzanet

From: Date: Tue, 06 Sep 2005 07:23:29 +0000
Subject: note 56511 deleted from function.include by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94780@lists.php.net to get a copy of this message
Note Submitter: Stevenm122084 at aol dot com ---- I decided to use the include function in one of my functions. It like to drove me crazy! I found two problems. 1.) Say you want to include a few strings, such as a conf file: L:\bin\conf\main.conf - <?php $classDir = "L:\bin\src\\"; .. .. .. ?> L:\bin\func\using.func - <?php include 'L:\bin\conf\main.conf'; function using($class) { $classFile = $classdir . $class; include $classFile; } Well, this doesn't work. I for awhile It was driving me nuts. I was even talking to the file, cursing it, telling it that it is stupid. Then for some reason or another I knew that it would work inside the function too. So, I put the include in the function as well: L:\bin\func\using.func - <?php function using($class) { include 'L:\bin\conf\main.conf'; $classFile = $classdir . $class; include $classFile; } And TADA!!! It worked. I just put this on here incase someone does the same stupid thing I did. on to the next problem, and a stupid one. 2.) Say you want to include a file in the previous directory: <?php include "../conf/main.conf"; .. .. ?> this doesnt work. For some dumb reason, the makers of PHP want you to include the name of the folder the php file is in then the '../': <?php include "func/../conf/main.conf"; .. .. ?> This works. There ya go if you wanted to know.

« previous php.notes (#94780) next »