Чтобы проиллюстрировать концепцию Destructor, что база данных обновляется, если значения изменения до объекта уничтожается следующий блок кода приведен в книге:Устный простой PHP код
<?php
class use {
private $_properties;
private $_changedProperties //Keeps a list of the properties that were altered
private $_hDB;
//_construct and __get omitted for brevity
function __set($propertyName, $value) {
if(!array_key_exists($propertyName, $this->_properties))
throw new Exception('Invalid property value!');
if(method_exists($this, 'set'. $propertyName)) {
return call_user_func(
array($this, 'set', $propertyName), $value);
}
else {
//If the value of the property really has changed
//and it's not already in the changedProperties array,
//add it.
if($this->_properties[$propertyName] !=$value && !in_array($propertyName, $this->_changedProperties)) {
$this->_changedProperties[] = $propertyName;
}
Остальной код был ненужный код и был опущен. Объясните, пожалуйста, код с точки:
if(method_exists($this, 'set'. $propertyName)) {
return call_user_func(
array($this, 'set', $propertyName), $value);
}
else {
//If the value of the property really has changed
//and it's not already in the changedProperties array,
//add it.
if($this->_properties[$propertyName] !=$value && !in_array($propertyName, $this->_changedProperties)) {
$this->_changedProperties[] = $propertyName;
}
Почему я спрашиваю это то, что я хочу, чтобы проверить мою интерпретацию/понимание кода.