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