cesarhtown Posted April 19, 2006 Share Posted April 19, 2006 Hey guys!This is the situation. I have a script that somebody else wrote. This guy has a main.php page that includes different .php pages. Those .php pages include other .php pages, and those include OTHER .PHP PAGES! in my opinion, the code is a mess! I've been trying my best to come up with the logic of all these pages put together, but it's riduclous... oh well... can anybody help with some kind of function that reads all variables that are passed on/included to the main.php page? it would be nice to enter a function that gives you a list of all the variables that are in play from those pages on main.php somewhere. Please help.Cesar. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 i dont think there is anything that you can just tack onto the bottom of your script that will tell you all the $variables you have in your script.If I'm right, then what you need to do is work through your code logically, and carefully.Start with main.php.When you find an include('file.php') go to that file, copy the code and paste it into main.php in place of the include... then do the same for the next include, and the next and the next, and so on.Eventually you'll have one very large main.php file which is easy to follow through and see what is doing what, and you can then split it down and include parts of it as you want to, rather than how it was put together in the first place. Quote Link to comment Share on other sites More sharing options...
cesarhtown Posted April 20, 2006 Author Share Posted April 20, 2006 Actually, I think I figured it out. I applied this code to my script:foreach ($GLOBALS as $k => $v){echo "\$GLOBALS[$k] => $v <br>";}That seems to do the trick, except for the variables that are arrays, but I guess I can loop into it, I just don't need them. Thanks for the advice. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 20, 2006 Share Posted April 20, 2006 cunning. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 20, 2006 Share Posted April 20, 2006 Use [code]<?php echo '<pre>' . print_r($GLOBALS,true) . '</pre>'; ?>[/code] This will do the "right thing" for the arrays and recursive arrays which exisit in the $GLOBALS array.Ken 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.