OOP

3 views
Skip to first unread message

Mohammed Jebrini

unread,
Sep 27, 2010, 3:06:06 PM9/27/10
to <?PHPalClub
create file with name oop1.php :
put this content inside the file ..

<?php

class oop1
{
public $class = 'First';

}


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

create another file oop2.php :

<?php
function __autoload($name)
{
require $name.'.php';
}

class MySecondPHPClass
{

private $name = null ;




public function test()
{

}



public function __set($variable, $value)
{
$this->$variable = $value ;
}

public function __get($variable)
{
return $this->$variable ;
}

public function setName($value)
{

$this->name = $value;
return $this;

}

function __isset($var)
{
isset($this->$var);
}

function __unset($var)
{
unset($this->$var);
}

function __construct($param)
{
echo " Construction ";

$oop1 = new oop1();
echo $oop1->class;
}

function __destruct()
{
echo " destruct ";
}


function __call($method,$arg)
{
echo $method ;

}

function __toString()
{
return "Name = ".$this->name;
}

function __clone(){}

}

$x = new MySecondPHPClass(10);
$x->setName('Name X ');
//var_dump(isset($x->name));
$x->setName('Mohammed');


$y = clone $x ;

//echo $x->name() ;
$y->setName('Name Y');
//echo $y."<br/>" ;
//$y->setName('Name Y');
//echo $x ;
Reply all
Reply to author
Forward
0 new messages