List All Objects Created on a Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
buckeye07
Forum Newbie
Posts: 1
Joined: Fri Mar 20, 2009 8:25 am

List All Objects Created on a Page

Post 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
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: List All Objects Created on a Page

Post 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)
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: List All Objects Created on a Page

Post 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);
Post Reply