note 68053 added to language.oop5.overloading
| From: | mnaul at nonsences dot angelo dot edu | Date: | Tue, 11 Jul 2006 19:58:46 +0000 |
| Subject: | note 68053 added to language.oop5.overloading | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114678@lists.php.net to get a copy of this message | ||
This is just my contribution. It based off of many diffrent suggestions I've see thought the
manual postings.
It should fit into any class and create default get and set methods for all you member variables.
Hopfuly its usefull.
<?php
public function __call($name,$params)
{
if( preg_match('/(set|get)(_)?/',$name) )
{
if(substr($name,0,3)=="set")
{
$name = preg_replace('/set(_)?/','',$name);
if(property_exists(__class__,$name))
{
$this->{$name}=array_pop($params);
return true;
}
else
{
//call to class error handler
return false;
}
return true;
}
elseif(substr($name,0,3)=="get")
{
$name = preg_replace('/get(_)?/','',$name);
if(property_exists(__class__,$name) )
{
return $this->{$name};
}
else
{
//call to class error handler
return false;
}
}
else
{
//call to class error handler
return false;
}
}
else
{
die("method $name dose not exist\n");
}
return false;
}
----
Server IP: 64.71.164.2
Probable Submitter: 72.18.170.178
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.oop5.overloading.php
Edit -- http://master.php.net/note/edit/68053
Del: integrated -- http://master.php.net/note/delete/68053/integrated
Del: useless -- http://master.php.net/note/delete/68053/useless
Del: bad code -- http://master.php.net/note/delete/68053/bad+code
Del: spam -- http://master.php.net/note/delete/68053/spam
Del: non-english -- http://master.php.net/note/delete/68053/non-english
Del: in docs -- http://master.php.net/note/delete/68053/in+docs
Del: other reasons-- http://master.php.net/note/delete/68053
Reject -- http://master.php.net/note/reject/68053
Search -- http://master.php.net/manage/user-notes.php