You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
528 B
27 lines
528 B
<?php
|
|
/**
|
|
* 使用foreach遍历可访问的属性(变量)
|
|
*/
|
|
|
|
class ClassA{
|
|
public $varA="varA";
|
|
protected $varB="varB";
|
|
private $varC="varC";
|
|
|
|
public function fnA(){
|
|
echo "fnA".PHP_EOL;
|
|
}
|
|
protected function fnB(){
|
|
echo "fnB".PHP_EOL;
|
|
}
|
|
|
|
private function fnC(){
|
|
echo "fnC".PHP_EOL;
|
|
}
|
|
}
|
|
|
|
$obj=new ClassA();
|
|
foreach($obj as $key => $value){
|
|
echo "$key:$value".PHP_EOL;
|
|
}
|
|
?>
|