<?php
/*
* RestrictedAccess(true)
*---------------------------------
* Properties can not be added at run-time
*/
class Test extends SafeObject
{
public function DoSomething() { echo 'Doing something...'; }
public function DoSomethingElse() { echo 'Doing something else...'; }
}
$o = new Test();
$o->RestrictedAccess(true)
->AllowedProperties(array('server','username'));
echo 'RestrictedAccess(true)<br/>-------------------------------<br/>';
// ok
$o->server = 'localhost';
echo '<br/>server: ' , $o->server;
// ok
$o->username = 'costin';
echo '<br/>username: ' , $o->username;
// NOT ok [Error: allowed properties cannot be unset while in restricted mode]
unset($o->username);
// NOT ok [Error: test is not part of the allowed properties]
$o->test = 'test';
echo '<br/>test: ' , $o->test;
?>
|