method_exists

method_exists

Listening Video

The method_exists() function will evaluate to see if the specified method exists. It returns TRUE if the method is found and FALSE if it is not. demo.php
<?php include_once("class1.php"); $myObj = new class1(); if(method_exists($myObj, "sayhello")){ echo $myObj->sayhello(); } else { echo "sayhello method does not exist"; } ?>
class1.php
<?php class class1 { public function sayhello(){ return "Hello"; } } ?>

0 Response to "method_exists"

Post a Comment