Uridium Posted September 20, 2010 Posted September 20, 2010 How many times do you come across the same procedure in scripts and find yourself repeating things over and over again heres a quick tip... create a file called actions.php and store all the widely used mentions in there example >>>> global $db,$ir,$c,$userid,$h; is used throuhout every script so in actions.php just add $callglobal "global $db,$ir,$c,$userid,$h;"; and in the file globals.php under the mention of header.php add include actions.php so now when ever you need to do >>> global $db,$ir,$c,$userid,$h; you just write it as $callglobal You can keep adding to the list things that you know are always the same... Quote
Equinox Posted September 20, 2010 Posted September 20, 2010 But for your example, I'm going to be calling useless data, everywhere. Lets say I have this: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Now, with the "$callglobal" idea, I'm calling $db,$ir,$c,$userid,$h when really I only need $h. I would suggest a function for this, but then you're typing out just as much as you would be without the function. I think you used a bad example, but I get what you're trying to say Quote
Zeggy Posted September 20, 2010 Posted September 20, 2010 Umm, I don't know what you're doing, that's not PHP. '$callglobal "global $db,$ir,$c,$userid,$h;";' gives a syntax error. Even if you have '$callglobal = "global $db,$ir,$c,$userid,$h;";', it is still just a string. There's no way you can use it to call actual php code, unless you use eval($callglobal); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.