|
Posted by Jerry Stuckle on 10/06/62 12:00
elmosik@gmail.com wrote:
> 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."
>
You should only be calling the constructor of the parent class in your
constructor.
> 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 ...?
>
You can have malicious code in any file. It's not restricted to class
files.
> Any ideas?
>
> Thanks in advance for help and sorry for my English.
>
No problem at all with your English :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|