- <?php
- error_reporting(-1);
- ini_set('display_errors','on');
- class A {
- public $a = 'hello';
- public function add() {
- $this->b = 'world';
- }-
- public static function p() {
- echo 'world',PHP_EOL;
- }-
- }
- $a = new A;
- $a->add();
- $a->c = 'test';
- $a->p();
- var_dump($a);
- world
- object(A)#1 (3) {
- ["a"]=>
- string(5) "hello"
- ["b"]=>
- string(5) "world"
- ["c"]=>
- string(4) "test"
- }
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)