Jump to content
MakeWebGames

Recommended Posts

Posted

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

Posted

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

Posted

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);

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.   Paste as plain text instead

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