I am sure this is something I'm doing wrong, but I just can't see it.  I
have the following in my test.php file:

<html>
<head>
</head>
<body>
<?php
class test {
  var $a;
  var $b = "goodbye";
  function c($arg) {
    $this->$a = $arg;
    echo "<p>a = " . $this->$a . "</p>\n";
    echo "<p>b = " . $this->$b . "</p>\n";
  }
}
$d = new test;
$d->c("hello");
?>
</body>
</html>

When I load the page, I expect to see the following output:

a = hello
b = goodbye

Instead, what I'm seeing is:

a = hello
b = hello

It seems that all variables in the class are taking the value of the last
assignment to any other variable in the class.

Can anyone tell me what mistake I'm making?  I'm using PHP 4.3.4 on an
up-to-date Fedora Core 1 system.

Much thanks,

-Richard

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to