object example

SimpleObject.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>objects in php</title>
</head>

<body>
 <h2 style="color:pink;">objects in php</h2>
 <div style="color:#aaf; text-align:left; padding-top:12px;">
 <?php
  class modon
  {
   function modon_method()
   {
    echo "I am a method inside the modon class."; 
   }
  }
   /*
  |------------------------------------------------------------
  | modon is a class & modon_method() is a method.
  |------------------------------------------------------------
  */
  
  $myObject = new modon;
   /*
  |------------------------------------------------------------
  | To initialize or fire up the object use new statement.
  | class modon is playing as object and assigned to a variable.
  |------------------------------------------------------------
  */
  $myObject->modon_method();
   /*
  |------------------------------------------------------------
  | we are accessing the method here.
  |------------------------------------------------------------
  */
 ?>
 </div>
</body>
</html>

No comments:

Post a Comment

leave your comments here..