Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class myClass{
- function __set($arg_1, $arg_2){
- echo "__set($arg_1, $arg_2)".PHP_EOL;
- if(is_array($arg_2)){
- echo "Setting array $arg_1 to $arg_2".PHP_EOL;
- }
- else {
- echo "setting string $arg_1 to $arg_2".PHP_EOL;
- }
- $this->$arg_1 = $arg_2;
- }
- function __get($arg){
- echo "showing $arg".PHP_EOL;
- return 'ERROR! variable does not exist';
- }
- }
- $mClass = new myClass();
- $mClass->hello = 'this and that';
- echo "Hi there: ". $mClass->hello.PHP_EOL;
- $mClass->hello_again = array('this and that');
- echo "Hi again: ".$mClass->hello_again.PHP_EOL;
- echo $mClass->hello_again_2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement