tcorbeil Posted March 29, 2007 Share Posted March 29, 2007 Do functions execute themselves as they are declared? Or do they only execute upon called on? The reason is, I created a function and I have nowhere in the code called on it but it still runs itself.. any ideas? T. Quote Link to comment Share on other sites More sharing options...
interpim Posted March 29, 2007 Share Posted March 29, 2007 it should only run when called... Quote Link to comment Share on other sites More sharing options...
tcorbeil Posted March 29, 2007 Author Share Posted March 29, 2007 interpim, if I showed you this function of variable declaration, is there something that catches your eye?? <?php function getvariables(){ $servername = $_SERVER['SERVER_NAME']; $documentroot = $_SERVER['DOCUMENT_ROOT']; $pagepath = $_SERVER['SCRIPT_NAME']; $pi = pathinfo($_SERVER['SCRIPT_NAME']); $slash = "/"; $pageroot = $pi['dirname']."/"; $global = $documentroot."/Global/"; $addgif = "http://www.xxxxxxx.com/Global/add.gif"; //setup for Metag Tag $filename = basename($pagepath, ".php"); //get the filename $formatname = str_replace("_", " ", $filename); //get the underscores out of it. $metatag = "xxxxxxx.com: ".$formatname; //add the site name in front. echo $servername."**"; echo $documentroot."**"; echo $pagepath."**"; echo $pi."**"; echo $slash."**"; echo $pageroot."**"; echo $global."**"; echo $addgif."**"; echo $filename."**"; echo $formatname."**"; echo $metatag."**"; } ?> this function seems to get caled twice during HTML load and nowhere have I got the function called... Quote Link to comment Share on other sites More sharing options...
Lytheum Posted March 29, 2007 Share Posted March 29, 2007 Hmm, when I use your function, it doesn't call it unless I call it. echo getvariables(); Quote Link to comment Share on other sites More sharing options...
btherl Posted March 29, 2007 Share Posted March 29, 2007 Here's a few ideas to try: 1. Temporarily change the name of the function. Do you get any errors coming up where it was being called from before? 2. Try changing the output of the function. Does the output of your script change? If no, then your function isn't being called.. it's another function which looks the same. Quote Link to comment Share on other sites More sharing options...
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.