Re: get_defined_vars in all scopes?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Anguz wrote:
> John Holmes wrote:
>
>>>I'm using this at the end of a script
>>>
>>>echo '<pre>'; var_dump(get_defined_vars()); echo '</pre>';
>>>
>>>but it only returns what get_defined_vars gives, which is what's
>>>available in the current scope. Is there any way to get also the vars
>>>used in functions that weren't globalized?
>>
>>
>> No, not unless you call this in the functions, also. The variables don't
>> exist after the function is completed.
>>
>> ---John Holmes...
>>
>> UCCASS - PHP Survey System
>> http://www.bigredspark.com/survey.html
>
> I see. Thank you John.
>
> Many functions may end at different places, they not alway reach the
> end, so I guess I could do it globalizing every var/arr, at least the
> ones I'm most interested in.

Gak!

Don't *DO* that!

When you make a variable global, you will introduct all *KINDS* of problems.

Better to find all your function definitions and do:

require 'dumbvars.inc';

inside of them.

You can then have dumpvars.inc dump out whatever variables you are trying
to track.

You could even set up dumpvars.inc to let you tweak a configuration file
or something to check the current file (__FILE__) or function and
http://php.net/define a global 'DEBUG' setting that will tell dumpvars.inc
whether to print out variables or not.

> Is there some program I can use that'll monitor the vars when executing
> the script? I think Xdebug [http://xdebug.org/] does that with
> functions, but am not sure if it'll work with vars.

What you describe is known as a "debugger" which typically comes in an
"Integrated Development Environment" (aka IDE)

So if you Google for "PHP IDE debugger" you will find your choices.

Zend Studio, Komodo (sp?), PHPEd, PHPEditor, spring to mind, but I'm sure
there are dozens of them out there.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux