What am I doing wrong?
| From: | Szii | Date: | Sun, 23 Apr 2000 08:00:46 +0000 |
| Subject: | What am I doing wrong? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13930@lists.php.net to get a copy of this message | ||
Um, what's wrong with this? My object seems to be getting corrupted...
<?php
session_start();
# require("classes/test.class");
if (!isset($user_object))
{
$user_object = new test();
session_register("user_object");
}
?>
<html>
<body>
Here is our object!<BR>
<?php $user_object->printvalues(); ?>
Now we don't use the constructor set, but
call it directly...<BR>
<?php $user_object->LoadStuff(); ?>
Here is the new object!<BR>
<?php $user_object->printvalues(); ?>
</body>
</html>
<?php
class test
{
var $one;
var $two;
var $three;
var $four;
var $five;
var $six;
var $seven;
var $eight;
var $nine;
var $ten;
function test()
{
$this->LoadStuff();
}
function LoadStuff()
{
$this->$one = "one1";
$this->$two = "two2";
$this->$three = "three3";
$this->$four = "four4";
$this->$five = "five5";
$this->$six = "six6";
$this->$seven = "seven7";
$this->$eight = "eight8";
$this->$nine = "nine9";
$this->$ten = "ten10";
}
function printvalues()
{
print ($this->$one . "\r\n<BR>");
print ($this->$two . "\r\n<BR>");
print ($this->$three . "\r\n<BR>");
print ($this->$four . "\r\n<BR>");
print ($this->$five . "\r\n<BR>");
print ($this->$six . "\r\n<BR>");
print ($this->$seven . "\r\n<BR>");
print ($this->$eight . "\r\n<BR>");
print ($this->$nine . "\r\n<BR>");
function printvalues()
{
print ($this->$one . "\r\n<BR>");
print ($this->$two . "\r\n<BR>");
print ($this->$three . "\r\n<BR>");
print ($this->$four . "\r\n<BR>");
print ($this->$five . "\r\n<BR>");
print ($this->$six . "\r\n<BR>");
print ($this->$seven . "\r\n<BR>");
print ($this->$eight . "\r\n<BR>");
print ($this->$nine . "\r\n<BR>");
print ($this->$ten . "\r\n<BR>");
}
}
?>