Kenai Posted May 27, 2008 Share Posted May 27, 2008 Hi there. I am a very new scripter, and have just now started using PHP (end of last week), and I have a question about implementation of my code. Background -> So that I can easily manage site navigation on my project site, I have created a script that takes info from a MySQL table, and generates a complex unordered list (to be used with Tanfa's Menus). I wish to use this script in all pages of my project site. (My testing server is XAMPP Lite for Windows (only mods are passwords), and my final destination is unmodded Bluehost) Problem -> I don't want multiple copies of the same script all over the place. I would like to make my script akin to a SuperGlobal, so that all I would need to do is put <?php ahopeforNav(); ?> in my pages, and it would make that nice list. As I am a novice scripter, as I learn more this would be best as I could change only the one function's code once, and it would be put into use on all pages. Question -> Is there any way to make a function that is callable from all pages on a site? I have google'd every keyword and phrase I can think of, but I didn't find anything. If anybody can help me, I would appreciate it (by the way, I am very ill today, so please forgive me if this post is somewhat incoherent or non-understandable. Normally I don't post to forums or message boards if I am ill, but my project work needs done post haste, and this is part of what I have to do. ) Link to comment https://forums.phpfreaks.com/topic/107404-make-function-akin-to-a-superglobal/ Share on other sites More sharing options...
kenrbnsn Posted May 27, 2008 Share Posted May 27, 2008 You need to put the function in a separate file and include that file in each script. Ken Link to comment https://forums.phpfreaks.com/topic/107404-make-function-akin-to-a-superglobal/#findComment-550644 Share on other sites More sharing options...
Kenai Posted May 27, 2008 Author Share Posted May 27, 2008 Thank you, Ken. I will read up on how to do this Link to comment https://forums.phpfreaks.com/topic/107404-make-function-akin-to-a-superglobal/#findComment-550646 Share on other sites More sharing options...
Kenai Posted May 27, 2008 Author Share Posted May 27, 2008 So that any newbies looking for the same find it faster... http://www.w3schools.com/PHP/php_includes.asp Link to comment https://forums.phpfreaks.com/topic/107404-make-function-akin-to-a-superglobal/#findComment-550680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.