- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
<?php
class Pet {
protected $name;
public function __construct($name) {
echo "Setting name to " . $name . "\n";
$this->name = $name;
}
public function eat() {
echo $this->name . " is eating.\n";
}
}
$var = 30;
$a_pet = new Pet("Spike");
$a_pet->eat();
?>
---
<?php
function Pet__construct(&$objInst, $name)
{
echo 'Setting name to ' . $name . '
';
$objInst['name'] = $name;
}
function Pet_eat(&$objInst)
{
echo $objInst['name'] . ' is eating.
';
}
$Pet = array('__vars' => array('name' => null));
$var = 30;
$a_pet = array_merge($Pet['__vars'], array('__type' => 'Pet'));
Pet__construct($a_pet, 'Spike');
Pet_eat($a_pet);