Monday, July 20, 2009

Simple oop in php use $this->. in diffrence file

This code is show how to use $this->var in php using oop implementation.

this file name file1.php.
---------------------------------------

include ("file2.php");

$classme = new Two;
$classme->valueone = "I love my name";
$classme->display(); // call function


this file name file2.php.
---------------------------------------

class Two{

function display(){
echo $this->valueone;
echo "
Do action, condition or anything here....";
}
}

----------------------------------------

Function display will have the value( $this->valueone): I love my name

Have fun!!!
Give your comment.... :)

No comments: