Re[2]: [PHP] Can Objects be passed to another page?
| From: | MuToGeN | Date: | Wed, 03 Sep 2003 12:47:29 +0000 |
| Subject: | Re[2]: [PHP] Can Objects be passed to another page? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-161547@lists.php.net to get a copy of this message | ||
Hello Marco,
I was saying about GET and POST, not sessions
MS> Hi there
MS> MuToGeN wrote:
>> No, arrays can be passed (<input name="array[2]">,
>> for example), but not objects.
MS> And why does this work then?
MS> === SCRIPT ===
MS> <?php
MS> error_reporting(E_ALL);
MS> class AClass {
MS> var $i = 0;
MS> function AClass ($i = 0) {
MS> //$this->display();
MS> }
MS> function increment() {
MS> $this->i++;
MS> }
MS> function display() {
MS> printf('Current value of $i is: %s<br>', $this->i);
MS> }
MS> }
MS> session_start();
MS> if (!isset($_SESSION['AClass'])) {
MS> $a = & new AClass();
MS> $_SESSION['AClass'] = & $a;
MS> }
MS> else {
MS> $a = & $_SESSION['AClass'];
MS> }
$a->>increment();
$a->>display();
?>>
MS> === /SCRIPT ===
--
Best regards,
MuToGeN mailto:mutogen@pisem.net