?? 07c08-1.php
字號(hào):
<?php// Define a class that will store values for any property it is given.class Data_Holder { // The data storage array private $data = array(); // A method to set any variable passed to this object. // Store it in the array public function __set($name, $value) { $this->data[$name] = $value; } // A method to return any values that are set: public function __get($name) { if (isset($this->data[$name])) { return $this->data[$name]; } } // A method that will allow 'isset' to work on these variables public function __isset($name) { return isset($this->data[$name]); } // Finally a method to allow 'unset' calls to work on these variables public function __unset($name) { unset($this->data[$name]); }}// Create a data holding object & store some data in it:$data = new Data_Holder();$data->name = 'Francesca';// Now echo the value out to see that the __get method is working:echo "<p>The data value of 'name' is {$data->name}</p>";// Now unset the value, and then use isset to ensure that it happened.unset($data->name);echo '<p>The value is ', isset($data->name) ? '' : 'not ', 'set.</p>';?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -