note 62591 added to function.get-class-vars
| From: | gizmobits at hotmail dot com | Date: | Sat, 04 Mar 2006 03:48:11 +0000 |
| Subject: | note 62591 added to function.get-class-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104814@lists.php.net to get a copy of this message | ||
I wanted a simple ToString() function that was automatic and class independent. I wanted to dump it
into any of several classes and get values quickly. I wanted to leave it there so I could customize
it for each class, so an outside function wasn't suitable. I came up with this and thought it
might be useful. Have fun!
<?php
function ToString () {
$s = "";
$s .= "<table>\n";
$s .= "<tr><td colspan=2><hr></td></tr>\n";
foreach (get_class_vars(get_class($this)) as $name => $value) {
$s .= "<tr><td>$name:</td><td>" . $this->$name .
"</td></tr>\n";
}
$s .= "<tr><td colspan=2><hr></td></tr>\n";
$s .= "</table>\n";
return $s;
}
?>
----
Server IP: 66.163.161.117
Probable Submitter: 68.117.97.121
----
X-Spam-Status: No, hits=4.0 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_20_30,HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.get-class-vars.php
Edit -- http://master.php.net/note/edit/62591
Del: integrated -- http://master.php.net/note/delete/62591/integrated
Del: useless -- http://master.php.net/note/delete/62591/useless
Del: bad code -- http://master.php.net/note/delete/62591/bad+code
Del: spam -- http://master.php.net/note/delete/62591/spam
Del: non-english -- http://master.php.net/note/delete/62591/non-english
Del: in docs -- http://master.php.net/note/delete/62591/in+docs
Del: other reasons-- http://master.php.net/note/delete/62591
Reject -- http://master.php.net/note/reject/62591
Search -- http://master.php.net/manage/user-notes.php