Forum Moderators: coopster

Message Too Old, No Replies

Script writing down all the variables

         

rokec

8:51 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



Can someone write me simple-sample script which will write down all variables used in document? echo($varname." = ".$varcontent);

Psychopsia

8:54 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



Use get_defined_vars [php.net]() function.

eelixduppy

8:55 pm on Dec 21, 2006 (gmt 0)



As stated in your other thread, get_defined_vars [us3.php.net] will return an array of all the defined variables up to that function call.

Example:


echo '<pre>';
print_r(get_defined_vars());
echo '</pre>';

Try this in a script where you included the file you want to protect to see what variables are being defined.

rokec

8:59 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



And how would i use form: echo($varname." = ".$varcontent);

eelixduppy

9:07 pm on Dec 21, 2006 (gmt 0)



If you use my above code you will see that the array produced has the variable name as the index of the array. The content part of the array for those indexes is the content of the variable--the array index one.

In order to get the format that you want you have to go through the array and echo the index and its content using a loop.

It is my understanding that you want the variables just to check to see if your included file is passing variables?

rokec

9:15 pm on Dec 21, 2006 (gmt 0)

10+ Year Member



Is it possbile to include the file just on the same server? Because if it is not true, then that could be a hacking tool...

jatar_k

9:57 pm on Dec 21, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



let's keep it in one thread
[webmasterworld.com...]