RE: php include problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I do this little trick in the main file I include in all my php files. So after that, I only use the constants regardless how deep I am in a folder.

//pour trouver comment/ou inclure les fichiers peut importe l'emplacement du fichier appelant
	if (!defined("SERVER_ROOT_PATH"))
	{    
		settype($str_pathUp, "string");
		$str_pathUp = str_repeat("../", substr_count($_SERVER['PHP_SELF'], "/")-2);    
		//on construit le chemin des fichiers       
		DEFINE("SERVER_ROOT_PATH", $str_pathUp);
		DEFINE("SERVER_FILE_PATH", SERVER_ROOT_PATH."fichier/");
		DEFINE("SERVER_INCLUDEFILE_PATH", SERVER_ROOT_PATH."includeFiles/");
		DEFINE("SERVER_IMAGE_PATH", SERVER_ROOT_PATH."image/");
		DEFINE("SERVER_CSS_PATH", SERVER_ROOT_PATH."css/");
		DEFINE("SERVER_TEMP_PATH", SERVER_ROOT_PATH."temp/");
		DEFINE("SERVER_LOG_PATH", SERVER_ROOT_PATH."log/");
		DEFINE("SERVER_CLASS_PATH", SERVER_ROOT_PATH."classe/");
		DEFINE("SERVER_ADODB_CLASS_PATH", SERVER_CLASS_PATH."adodb/");
		DEFINE("SERVER_MAIL_CLASS_PATH", SERVER_CLASS_PATH."mail/");
		DEFINE("SERVER_NEWMAIL_CLASS_PATH", SERVER_CLASS_PATH."phpmailer/");
		DEFINE("SERVER_ERROR_CLASS_PATH", SERVER_CLASS_PATH."errorHandler/");
		DEFINE("SERVER_SESSION_CLASS_PATH", SERVER_CLASS_PATH."session/");
		DEFINE("SERVER_SQL_CLASS_PATH", SERVER_CLASS_PATH."sqlWrapper/");
	}
	
	// Fonctions générales nécessaires à certaines classes.
	include_once(SERVER_INCLUDEFILE_PATH.'module_fonction_generale.php');





-----Message d'origine-----
De : Niel Archer [mailto:Niel Archer] De la part de Niel Archer
Envoyé : 28 mars 2007 21:32
À : php-windows@xxxxxxxxxxxxx
Objet : Re:  php include problem

Hi

> When including try using ./new/images instead of /new/images
> 
> the . should tell it to start at root level.

No. the '.' tells it to start at current directory. '../' would tell it
to start at the parent directory (one level higher) so:

 "../images/"
 would work in this example.

bob's advice to use absolute paths would be safest though...

"www.your-domain.com/images/"



Niel

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux