note 52154 added to function.var-export

From: Date: Fri, 22 Apr 2005 13:37:59 +0000
Subject: note 52154 added to function.var-export
Groups: php.notes 
Request: Send a blank email to php-notes+get-88402@lists.php.net to get a copy of this message
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 ---- Manual Page -- http://www.php.net/manual/en/function.var-export.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52154 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52154&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52154&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52154&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52154&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52154&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52154&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88402) next »