is object function in php example

php example code : is_object function in php

is-object-php-example.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <title>php example code : is_object function in php</title>
 </head>
 <body>
  <h3>php example code : is_object function in php</h3>
  <?php
   /*
    ----------------------------------------------------------------------------
    let us make an object and test it wheather it is object or not
    by using php is_object function
    ----------------------------------------------------------------------------
   */
   class SimpleObject
   {
    function SimpleObjectFunction()
    {
     return true;
    }
   }
   
   $myObject = new SimpleObject();
   
   $objectFlag = is_object($myObject);
   
   if($objectFlag == true)
   {
    echo 'it is an object';
   }
   else
   {
    echo 'it is not an object';
   }
   
   echo "<br><br>";
   /*
    ----------------------------------------------------------------------------
    let us make a non object and test it wheather it is object or not
    by using php is_object function
    ----------------------------------------------------------------------------
   */
   $myObject = NULL;
   
   $objectFlag = is_object($myObject);
   
   if($objectFlag == true)
   {
    echo 'it is an object';
   }
   else
   {
    echo 'it is not an object';
   }
  ?>
 </body>
</html>


php example code : is_object function in php - output in the browser

No comments:

Post a Comment

leave your comments here..