PC Nerd Posted April 6, 2007 Share Posted April 6, 2007 is there a way to echo out every value defined and set on a page, without manually doing so? if so wha is it. if not, how shoudl i go about it? thankx Quote Link to comment Share on other sites More sharing options...
joquius Posted April 6, 2007 Share Posted April 6, 2007 What exactly is it for? Could you just use an array like '$page_vars' or something? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 6, 2007 Share Posted April 6, 2007 You should look at the function get_defined_vars() Ken Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 thanks, will do Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 ok, ive done that when it comes to echoing the database link stuff, it says that mysqli_object cannot be converted to string, so how do i catch that error and replase it with the string eg "MYSQL OBJECT" this is what i have: $page_variables = get_defined_vars(); foreach($page_variables as $field1 => $value1) { if(is_array($array1)) { foreach($field1 as $field2 => $value2) { echo $field2." => ".$value2."<br>"; } } else{ echo $field1." => ".$value1."<br>"; } } i only have variables and arrays, from memory no multidimentional arrays....... but i know that ive got for example a loop that loops througha mysql result, and there are many records int he result, so i used the while(var = mysqli_fetch_array) so how do i get those values ( if i cant thats ok) thankx Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 6, 2007 Share Posted April 6, 2007 If you just want to see what's in the array, you can do: <?php $page_variables = get_defined_vars(); echo '<pre>' . print_r($page_variables,true) . '</pre>'; ?> Ken Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 thats pretty much perfect 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.