Jump to content

[SOLVED] PHP Global Functions?


random1

Recommended Posts

Hi all,

 

I'm a mid-level PHP developer and I'd like to know if it's possible to create global functions in PHP.

 

i.e. functions that are available to ALL pages (included and required ,php files too) in the website.

 

I currently have a require() function working to force include a .php file with a call to a function but instead of triggering the function it simply prints out:

 

generateLink("http://www.google.com", "lnk_google", "Go to Google", "_blank", "", "This link takes you to Google in a new window");

 

Am I taking the wrong approach?  ???

Link to comment
Share on other sites

Thanks for the quick replies.

 

I have an "index.php" page requires() an included file called "inc_functionspagecreation.php".

 

"index.php" (a template page) then requires a page called "home.php".

 

I'd like "home.php" to have full access to functions in "inc_functionspagecreation.php".

Link to comment
Share on other sites

If the inc_functionspagecreation.php is included to index.php and home.php is included to index.php, home.php should have access to all the functions in inc_functionspagecreation.php

 

If it is just printing it out as text then for some reason the php engine isn't parsing it; which is most likely do to a missing php tags <?php ?> (as PFMaBiSmAd suggested).

 

However, without posting the relevant code(s), there is no way for us to tell. Right now were just poking around in the dark...

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.