Hello sam1600,

Wednesday, January 10, 2001, 7:44:44 PM, you wrote:

>> $d->somevar = true;
>> and the next call to $d->b() will print nothing.
>> But you won't be able to assign a value to $somevar, if it is not
>> declared in the class.

sic> This does not appear to be true.  With error reporting set to max, and the 
sic> variables not defined in the class ( $somevar,$somevar2 and $somevar3 ),
sic> the following will echo out:
sic> Not set
sic> empty
sic> value of somevar2
sic> value of somevar3

sic> class a {
sic>    function b(){
sic>      if (!isset($this->somevar))
sic>           echo "Not set<br>";
sic>      if (empty($this->somevar))
sic>          echo "empty<br>";
sic>       }
sic>    }
sic> $d = new a;
$d->b();
$d->somevar2 = "value of somevar2<br>";
$d->somevar3 = "value of somevar3<br>";
echo $d->somevar2;
echo $d->somevar3;

try to assign something to $d->somevar if it is not declared in the
definition.


>> the method b() of the class a will break if you don't declare $somevar
>> in the class definition. In the string "if (!isset($this->somevar))"
>> it would throw an error saying that you have no variable named 'somevar' in
>> you class.

sic>  This does not appear to be true either, see above.

bad practice anyway

-- 
Best regards,
Max A. Derkachev mailto:[EMAIL PROTECTED]
Symbol-Plus Publishing Ltd.
phone: +7 (812) 324-53-53
http://www.Books.Ru -- All Books of Russia
 



-- 
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