Page 1 of 1

define function from other files

Posted: Wed Feb 21, 2007 3:47 am
by Ju-Pao
Is there a way in PHP to use the define function from another file in another directory in your PHP code?

For example my code is in this directory /home/dirA/dirB/dirC/

the the define function was from the directory /home/dirA/
define('KEYWORD',boi);

how can i use it in my code so that if I echo KEYWORD, it will display boi
without putting the define function in my code.

thank you guys for your help

Posted: Wed Feb 21, 2007 5:33 am
by volka

Posted: Wed Feb 21, 2007 5:39 am
by onion2k
Or include(). They're not the same.

Posted: Wed Feb 21, 2007 5:56 am
by Kieran Huggins
you'll have to include() the file - you can alternatively add this to every file using "auto_prepend_file" in php.ini

Posted: Wed Feb 21, 2007 10:03 pm
by Ju-Pao
thanks for the reply guys,

additional question how can I include a file from a different directory?

I use include_path='.:/var/www/html/dir1';

but it doesn't seem to work or it is not what I need
I already figured it out

just to share, I use include("/dir/somefile.txt");


:D I never thought it was this simple, hehehe