Friday 20 December 2013

Class and object - basic example

Here i show an example in PHP, how to create a object for a class and how to call a function using object.

Example:

<?php

// create a simple class
class Myclass
{
   function fun_name()
   {
      echo "Hello world";
   }
}

//create an object & call the function
$object = new Myclass;
$object ->  fun_name();

?>

Output:

Hello world

// by Anbu.A

No comments:

Post a Comment