Jump to content

functions in include file: Call to undefined function


funzoh

Recommended Posts

Hi there,

 

I have already read some other topics concerning the same problem I am encountering.

I have multiple applications which I programmed in PHP. In all of these applications I use a central authentication database and a central translation database (also on PHP).

 

For this to work, I need to include a functions.php file for both the authentication db as for the translation db in all of my sites. Because I use different URL's for all my apps, including auth and transl, I am forced to use an URL when including both the functions.php files of the auth db and the transl db.

 

As I found out (the hard way) PHP5 doesn't include the raw data of my functions.php files into the calling files, so none of my functions are known and I receive an error  "Call to undefined function ...".

 

Since I am using these programs only on an internal network (not public available), I am not afraid of any security issues. Is there any way I can include my functions.php files using an URL (like include ('http://trans.mysite.com/sys/functions.php');) so the defined functions in the functions.php file are known for the calling page?

 

I hope I am not too confusing you all with my story, but I would really be very greatfull with some help. If needed I can also provide you with some more coding I used and configuring.

 

I already checked my php.ini file and the following settings have already been applied:

allow_url_fopen = On

allow_url_include = On

short_open_tag = On

 

Many thanks in advance.  :shrug:

Link to comment
Share on other sites

The file is indeed actually included. I have added an echo before the first function and one after the last one. Both were shown in the page. Also the include is added before the use of the first function.

When I include the file locally on the server like this:

include('./sys/functions.php');

, the functions work perfectly. When I include it as an URL like this:

include('http://trans.mysite.com/sys/functions.php');

, they don't (but an echo does show up...).

 

I think this might be some security setting in my php.ini file, but I am not sure which...

Link to comment
Share on other sites

The only way you can use a URL to do this is if the file being requested does not get parsed/executed as a php file. You would either need to disable the php language engine for that file or use a file extension that does not invoke the php language. If you do this, you won't be able to put any security related settings into the file being included as that information would be available to anyone who happens to find the file and request it themselves. You could have the file in an encrypted format and decrypt it after it was included, but that would add even more time to your page generation time every time you included a file.

 

And, you do realize that using a URL in an include statement takes 50 - 100 times longer to execute than doing this through the file system.

Link to comment
Share on other sites

OK, as I understand there is a possibility to do so but it is not recommended as it takes way longer then going through the local filesystem of the server, which is very logical. I have concidered all of your replies and I will use a central place on the filesystem where I will place the files I want to manipulate centrally and include them by navigating to them from the root of my webserver.

 

Many thanks to you all for helping me out!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.