PHP 8.5.0 Alpha 2 available for testing

Voting

: min(nine, three)?
(Example: nine)

The Note You're Voting On

Nanhe Kumar
11 years ago
<?php

class Student {

protected
$_name;
protected
$_email;


public function
__call($name, $arguments) {
$action = substr($name, 0, 3);
switch (
$action) {
case
'get':
$property = '_' . strtolower(substr($name, 3));
if(
property_exists($this,$property)){
return
$this->{$property};
}else{
echo
"Undefined Property";
}
break;
case
'set':
$property = '_' . strtolower(substr($name, 3));
if(
property_exists($this,$property)){
$this->{$property} = $arguments[0];
}else{
echo
"Undefined Property";
}

break;
default :
return
FALSE;
}
}

}

$s = new Student();
$s->setName('Nanhe Kumar');
$s->setEmail('[email protected]');
echo
$s->getName(); //Nanhe Kumar
echo $s->getEmail(); // [email protected]
$s->setAge(10); //Undefined Property
?>

<< Back to user notes page

To Top