Skip to content

Commit afe282b

Browse files
committed
update
1 parent 68a3e41 commit afe282b

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
class Car
3+
{
4+
public $name;
5+
6+
// __construct ([ mixed $args = "" [, $... ]] ) : void
7+
function __construct($name = null)
8+
{
9+
$this->name = $name;
10+
echo ("Constructor is called\n");
11+
}
12+
13+
public function say()
14+
{
15+
echo "My name is $this->name\n";
16+
}
17+
18+
// __destruct ( void ) : void
19+
function __destruct()
20+
{
21+
echo "Destroying " . __class__ . "\n";
22+
}
23+
24+
// public __call ( string $name , array $arguments ) : mixed
25+
public function __call($name, $arguments)
26+
{
27+
echo "Calling object method '$name', Arguments: " . implode(', ', $arguments) . "\n";
28+
}
29+
30+
// public static __callStatic ( string $name , array $arguments ) : mixed
31+
public static function __callStatic($name, $arguments)
32+
{
33+
echo "Calling static method '$name', Arguments: " . implode(', ', $arguments) . "\n";
34+
}
35+
36+
// public __set ( string $name , mixed $value ) : void
37+
public function __set($name, $value)
38+
{
39+
echo "Setting '$name' to '$value'\n";
40+
$this->$name = $value;
41+
}
42+
43+
// public __get ( string $name ) : mixed
44+
public function __get($name)
45+
{
46+
echo "Getting '$name'\n";
47+
return $this->$name;
48+
}
49+
50+
// public __isset ( string $name ) : bool
51+
public function __isset($name)
52+
{
53+
echo "Is '$name' set?\n";
54+
return isset($this->$name);
55+
}
56+
57+
// public __unset ( string $name ) : void
58+
public function __unset($name)
59+
{
60+
echo "Unsetting '$name'\n";
61+
unset($this->$name);
62+
}
63+
64+
}
65+
66+
// __construct
67+
// $bmw = new Car;
68+
$bmw = new Car('X1');
69+
$bmw->say();
70+
$bmw->runTest('Hi', 123);
71+
Car::runTest('Hello', 123);

0 commit comments

Comments
 (0)