[PHP] Re: include (or require) doesn't seem to work
Thanks Torsten! Using the file-system relative path made it work (I had tried only with the absolute path, which ddidn't work). However, I checked again and I did have 'allow_url_fopen = On' in /etc/php.ini. I'll take a closer look later and report the problem if I find it. Thanks again, Daniel "Torsten Roehr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Try including it as a local file: > > require_once library.php'; // if it is in the same directory as the file > you > > Forgot a quote here, sorry: > require_once 'library.php'; > > Torsten -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] include (or require) doesn't seem to work
Hi, I'm almost ashamed to ask this question as surely enough the problem is something very basic but, nonetheless, I can't put my finger on it. I'm trying to implement the concept of a library (library.php) on PHP where I define (once) all auxiliary functions and then use them in a file (for instance index.php) via the 'require' or 'include' constructs. Here's a reduced version of what I'm doing: index.php: "; require("http://tristan/library.php?lang=$lang";); my_function("en"); ?> library.php: "; function my_function($lang = "es") { echo "my_function() says $lang"; } echo "library.php: loaded"; ?> When I load index.php I get the following: index.php: include_path is .:/usr/local/php/4.3.6/lib/php library.php: Called with tristan://library.php?lang=es library.php: loaded Fatal error: Call to undefined function: my_function() in /www/htdocs/index.php on line 5 It seems that the name space on index.php never gets updated with the function definitions made on library.php. What am I doing wrong? Thanks! Cheers, Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php