note 113924 added to reflectionclass.construct
| From: | nulled | Date: | Wed, 18 Dec 2013 03:42:06 +0000 |
| Subject: | note 113924 added to reflectionclass.construct | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197966@lists.php.net to get a copy of this message | ||
if (is_file($classfile))
require_once $classfile;
if (! class_exists($classname, false))
exit('ERROR: ' . $classname . ' is not defined as a Class');
The above code is useful to tell if the class was defined. You could also use another commentors
method using Try Catch Exceptions. But, if you do not use try blocks much, the above function based
method works just fine.
From there, you can than call:
$class = new ReflectionClass($classname);
if (! $class->isSubclassOf('PanelCommon'))
exit("ERROR: {$classname} must extends PanelCommon");
if (! $class->isUserDefined())
exit("ERROR: {$classname} must be user defined and not internal to PHP");
if (! $class->IsInstantiable())
exit("ERROR: {$classname} must be IsInstantiable and not an Interface or Abstract
class");
if (! $class->hasMethod('home'))
exit("ERROR: {$classname} lacks required method/function home()");
Forforth and so on.
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/reflectionclass.construct.php
Edit -- https://master.php.net/note/edit/113924
Del: integrated -- https://master.php.net/note/delete/113924/integrated
Del: useless -- https://master.php.net/note/delete/113924/useless
Del: bad code -- https://master.php.net/note/delete/113924/bad+code
Del: spam -- https://master.php.net/note/delete/113924/spam
Del: non-english -- https://master.php.net/note/delete/113924/non-english
Del: in docs -- https://master.php.net/note/delete/113924/in+docs
Del: other reasons-- https://master.php.net/note/delete/113924
Reject -- https://master.php.net/note/reject/113924
Search -- https://master.php.net/manage/user-notes.php