Page 1 of 1

List All Objects Created on a Page

Posted: Fri Mar 20, 2009 8:36 am
by buckeye07
I'd like to get a list of all objects that have been created so far on a page. I'm looking for a function similar to get_defined_vars, but I can't find one.

I'm working in a template file (joomla) and I'd like to know what variables have already been set on the page. I thought that get_defined_vars would help me, but it only lists variables that exist outside of objects. So, I need to first get a list of all the objects in the page, then use get_object_vars().

Thanks,
Julie

Re: List All Objects Created on a Page

Posted: Fri Mar 20, 2009 8:47 am
by Mark Baker
get_declared_classes() to get a list of all class definitions used

Or something like:

Code: Select all

 
$classes = array();
foreach(get_defined_vars() as $varName) {
   if (gettype($varName) == 'object') {
      $classes[] = get_class($$varName);
   }
}
 
 
(Not tested)

Re: List All Objects Created on a Page

Posted: Fri Mar 20, 2009 9:30 am
by php_east
buckeye07 wrote:I'm working in a template file (joomla) and I'd like to know what variables have already been set on the page.
Julie
at template level is only JDocumentHTML Object.
i don't think you can get other objects, they are out of scope, they would have been rendered and stored in its output buffer, waiting to be dispensed out soon after the template.

you can try print_r($this); or var_dump($this); in your template index.php.
there may be some things useful there you can play with perhaps.
another one is var_dump($mainframe);