note 52154 deleted from function.var-export by aidan
| From: | aidan@php.net | Date: | Sun, 01 May 2005 04:59:33 +0000 |
| Subject: | note 52154 deleted from function.var-export by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-88812@lists.php.net to get a copy of this message | ||
Note Submitter: james at colossalus dot com
----
In reference to the _var_export() function I created, here is an example of its use:
Example:
<?
$t->em = "!";
$t->k[0] = "ok";
$t->n[0]->o->a = "A";
$t->n[0]->o->b = "B";
$t->n[0]->o->c = "C";
$t->n[0]->o->d->q1 = "Q";
$t->n[0]->o->d->q2 = array("1","2",null);
$t->n[0]->o->d->q2[2]->a = "A";
$t->n[0]->o->d->q2['k']->a = "A";
$t->n[x] = "X";
$t->n["y"] = "Y";
$n = 1.1;
$txt1 = "hi!\r\n";
$txt2 = 'hi!\r\n';
$code1 = _var_export($t, true);
$code2 = _var_export($n, true);
$code3 = _var_export($txt1, true);
$code4 = _var_export($txt2, true);
echo "<pre>$code1\r\n\r\n$code2\r\n\r\n$code3";
echo "\r\n\r\n$code4\r\n\r\n</pre>";
?>
The above example will output:
-----------------------------
new _stdClass_();
class _stdClass_ {
var $em = "!";
var $k = array (
'0' => "ok"
);
var $n = array (
'0' => null /*(object)_stdClass_*/,
'x' => "X",
'y' => "Y"
);
function _stdClass_() {
$this->n[0]->o = null /*(object)_stdClass_*/;
$this->n[0]->o->a = "A";
$this->n[0]->o->b = "B";
$this->n[0]->o->c = "C";
$this->n[0]->o->d = null /*(object)_stdClass_*/;
$this->n[0]->o->d->q1 = "Q";
$this->n[0]->o->d->q2 = array (
'0' => "1",
'1' => "2",
'2' => null /*(object)_stdClass_*/,
'k' => null /*(object)_stdClass_*/
);
$this->n[0]->o->d->q2[k]->a = "A";
$this->n[0]->o->d->q2[2]->a = "A";
}
}
1.1
"hi!\r\n"
"hi!\\r\\n"
-----------------------------
If this helps you, please fire me an email and let me know!
Thanks, James W