php:面向对象之成员变量(数组)
一、PHP源码
1 <?php 2 3 class DATA{ 4 public $dlt_data = ""; 5 6 // set value of $dlt_data by ARRAY 7 function set_value($array_type) 8 { 9 $this->dlt_data = $array_type; 10 } 11 } 12 13 14 function display_data($DATA_type) 15 { 16 foreach($DATA_type->dlt_data as $k=>$v) 17 { 18 echo $k . " => " . $v . PHP_EOL; 19 } 20 } 21 22 23 $DATA_object = new DATA; 24 $array_laohu = array("book1"=>"gold", "book2"=>"wood", 3=>"water"); 25 26 $DATA_object->set_value($array_laohu); 27 28 //set value of '$DATA_object->dlt_data' by another way. 29 $DATA_object->dlt_data["book4"] = "earth"; 30 31 display_data($DATA_object); 32 33 ?>
二、PHP源码的运行结果
标签:type,data,object,面向对象,数组,dlt,array,php,DATA From: https://www.cnblogs.com/lnlidawei/p/16590231.html