Posted by elmosik on 11/11/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.
[Back to original message]
|