Creating a new object and assigning it to a variable : Objects « Class « PHP






Creating a new object and assigning it to a variable

 
<?php
Class Cat {
  // Constructor
  function __constructor(  ) {
  }

  // The cat meows
  function meow(  ) {
    echo "Meow...";
  }

  // The cat eats
  function eat(  ) {
    echo "*eats*";
  }

  // The cat purrs
  function purr(  ) {
    echo "*Purr...*";
  }
}

$myCat=new Cat;
?>
  
  








Related examples in the same category

1.Comparing Objects with == and ===
2.Create a new class and create an instance then use its property and method
3.Object Initialization
4.Object Overloading
5.Object Properties
6.Object Type Information
7.Objects Within Objects