You are here: Getting class object information from file. « PHP Programming Language « IT news, forums, messages
Getting class object information from file.

Posted by elmosik on 10/01/81 12:00

Is there any method to get this informations from php file?

1. Class methods
2. Check whether class in file is extended by 'XXX' or not (class
MyClass extends XXX ...)

- Class has same name as files e.g. file named 'myclass.php' has class
named 'myclass' etc...

I'm trying to do that tasks from list in that way:

-----------------------------------------------------
$class = 'myclass';

ob_start();

include($class.'.php');

// Creating object instance
$oClass = new $class;

// Check if $class extends XXX
if ( is_subclass_of( $oClass, 'XXX' ) )
{
// Class extends XXX
}

ob_end_clean();
--------------------------------------------------------

Yea, it's simple and working, but what happen when in __construct()
method in that class we try to run function from parent class:

------------------------------ myclass.php ---------------
class MyClass extends XXX
{
public __construct()
{
$this->method_from_XXX_class();
}
}
------------------------------------------------------------------

.... and what now? we've got a nice error while including myclass.php
and creating instance (new MyClass): "Call to a member function
method_from_XXX_class() on a non-object."

It's also dangerous because of potentially malicious code in included
file, but how can I get in other way? The only one solution that I
have in my mind is using regular expressions to extract interesting
data or ...?

Any ideas?

Thanks in advance for help and sorry for my English.

 

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

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