Jump to content

Recommended Posts

Team,

    I am trying to create an external file for my common functions to be called by other files. 

 

My functions.php file looks like this:

<?

function some_function{ blah; blah; }

?>

 

My main file looks like this:

 

<?

include('../functions.php');  // seems to be working correctly to this point

some_function();  //when I call this function the PHP hangs and I don't even get an error, just a white screen of death!

?>

 

    It appears like the include portion is work correctly, but the some_function(); is not working.  I have a ton variables that are  ???defined in the main file that need to be used by some_function.  I read all of the websites on this topic and I can't figure it out.  Does someone have a good example I can follow?  Is there a rule about parsing or something?  Do I need to change functions.php to functions.inc?  Wouldn't that be a security concern because someone could access functions.inc and download it?  I have passwords and stuff that I need to keep secure in functions.php!

  Incidentally I checked and the function runs in the main file correctly with all of it's contents.  I just can't remove it and put it in the external functions.php and call it properly!  Doh!  Thanks for any of your expert advice in advance!

 

-Max

Link to comment
https://forums.phpfreaks.com/topic/124982-solved-functions-in-include-files/
Share on other sites

It does appear as if it isn't calling the file correctly.  The functions.php is in the root with the main page. 

 

 

Warning: include(../functions.php) [function.include]: failed to open stream: No such file or directory in /home/u3/markmax33/html/Beta/testme.php on line 7

 

Warning: include() [function.include]: Failed opening '../functions.php' for inclusion (include_path='.:/usr/local/share/pear') in /home/u3/markmax33/html/Beta/testme.php on line 7

 

Fatal error: Call to undefined function get_user_id() in /home/u3/markmax33/html/Beta/testme.php on line 38

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.