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 Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/ 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? Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222729 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 Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222731 Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 thanks, will do Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222734 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 Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222737 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 Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222742 Share on other sites More sharing options...
PC Nerd Posted April 6, 2007 Author Share Posted April 6, 2007 thats pretty much perfect Link to comment https://forums.phpfreaks.com/topic/45839-solved-echo-values/#findComment-222749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.