you do this in the class constructor

class foo
{

  var $bar;

  function foo($fooval)
 {
    $this->bar=$fooval;
 }

}

hope that helps

Ankur Verma
HCL Technologies
A1CD, Sec -16
Noida, UP
India

----- Original Message -----
From: "Joseph H Blythe" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Wednesday, February 14, 2001 9:27 AM
Subject: [PHP] help with classes


> hey all,
>
> Was just wondering how to do the following:
>
> <?php
> class Foo {
>
> var $bar = $foo; // causes parse error
> var $bar = "$foo"; // causes parse error
> var $bar = '$foo'; // works but $foo is not evaluated
>
> }
> ?>
>
> So how does one correctly assign a variable to a variable inside a class
withot doing something like:
>
> var $bar = '';
> $this->bar = $foo;
>
> Any insight would be much appreciated.
>
> Regards
>
> Joseph
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to