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
https://forums.phpfreaks.com/topic/78516-solved-php-global-functions/
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".

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.