1.PHP反射
<?php ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); class Test { private $c = 1; public function a($id) { echo 'ok a'.$id; } private function b($id = 10018){ echo 'ok b'.$id; } } $testClass = new ReflectionClass('Test'); $instance = $testClass->newInstance(); $method = $testClass->getmethod('b'); $method->setAccessible(true); $method->invoke($instance, 3); $instance->a(1); var_dump($testClass->getProperty('c'));