i need to check if there is a method exists on my class or not before i call it here is my code :
Code:
<?php
class elements{
function add($t){
if(class_exists($t)){
$c = new $t;
return $c;
}else{
echo 'class dos\'not exists';
}
}
}
class qw{
function render(){
echo 'ahmed saber amin';
}
}
$e = new elements();
$e->add('qw')->renders();
?>
Comment