Andrew Falanga wrote:
> Hi,
>
> I'm trying to learn how PHP classes work. I'm very familiar with C++
> and such, but something that I thought should work is giving me
> grief. Basically, this is what I have.
>
> class myclass {
> private $somevar;
>
> public __construct($value) {
> $this->$somevar = $value;
> }
> }
>
> Then, in my other code I have:
>
> require("path/to/library.php");
>
> $obj = new $myclass("assign it this");
>
>
> When I attempt to load this page in my browser, I'm greeted with this
> error:
>
> Cannot access empty property in /usr/local/www/data-dist/mch/library/
> generic_table.php on line 19
>
> This is coming from the variable assignment in my c-tor in the class
> definition. Why isn't this working and how would I make it work?
>
> Andy
>
Andy,
Just minor problem - but a common one. It should be
$this->somevar = $value;
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================