How to use get_class() function to get the name of the class of the given object in PHP

1 Answer

0 votes
class Test 
{
    private $s;
      
    public function setS($s)
    {
        $this->s = $s;
    }
  
    public function getS()
    {
        return "s =  " . $this->s;
    }
}
    
$obj = new Test();
   
echo "Class name is: " , get_class($obj) , "<br />";
 
 
/*
run:
 
Class name is: Test
    
*/

 



answered Mar 14, 2016 by avibootz
...