You are here: Re: print out variable name as well as its content « PHP Programming Language « IT news, forums, messages
Re: print out variable name as well as its content

Posted by macca on 10/19/07 01:08

Just an idea, but look up get_defined_vars() in the manual.

e.g.

<?php

// Test Variables

$test_var1 = 1;
$test_var2 = 2;
$another_var = "hello";

/*
get_defined_vars() returns a multidimensional array containing a
list
of all defined variables, be them environment, server or user-
defined
variables
*** WITHIN THE SCOPE get_defined_vars() IS CALLED ***

*/


$arr = get_defined_vars();

foreach ($arr as $key=>$value){

// Shows the different vars you can access
//each one is an array of the vars in that category


switch($key){
case "GLOBALS":
continue 2;
break;
case "_POST":
continue 2;
break;
case "_GET":
continue 2;
break;
case "_COOKIE":
continue 2;
break;
case "_FILES":
continue 2;
break;
}

echo $key ." => ". $value ."<br />";
}


//========================

/*
Outputs

test_var1 => 1
test_var2 => 2
another_var => hello

*/


?>



Regards,

Paul

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация