Hello sam1600,
Wednesday, January 10, 2001, 9:55:34 PM, you wrote:
sic> Assigning something to $d->somevar when it is not declared in the
sic> definition works fine.
Well, if it still does assign to an undefined class property, I'm not sure
that this behavior will remain in the future since it v
riginal Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 10, 2001 3:31 PM
Subject: Re: Re[2]: [PHP] declaring variables in class
definitions
> Hi Toby,
>
>
> >This isn't really aesthetics as much as it is
organization.
>
>
Hi Toby,
>This isn't really aesthetics as much as it is organization.
>You already know that you don't have to declare PHP
>variables... if I had a one-line script that simply said:
>
>I would end up with 1 as the output. myVar would be created
>as soon as PHP encountered it (it would be empty,
;
To: <[EMAIL PROTECTED]>
Sent: Wednesday, January 10, 2001 1:55 PM
Subject: Re: Re[2]: [PHP] declaring variables in class
definitions
>
> Max,
>
> Thanks for your response.
>
> Assigning something to $d->somevar when it is not declared
in the
> definition works fin
They don't break the classes per se, but it definately promotes good OOP
structure. Keep this in mind for PHP 5 and PHP 6 which might (who knows) bring
us more strict OOP rules (ie private and public variables). In which case your
classes would have to be entirely rewritten instead of just puttin
Max,
Thanks for your response.
Assigning something to $d->somevar when it is not declared in the
definition works fine.
As far as I can tell, and from what we have found here, there is
absolutly no reason whatsoever to define variables in class definitions.
If someone can show me me a reason
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 reportin
Hi Max!
--- you wrote:
> Hello sam1600,
>
> Wednesday, January 10, 2001, 6:42:58 AM, you wrote:
>
> sic> What in the world is reason for declaring the following in the class?:
> sic> var $somevar;
> sic> I see no reason, and no differences if I don't declare: var $somevar;
>
> Classes are int
Hello sam1600,
Wednesday, January 10, 2001, 6:42:58 AM, you wrote:
sic> What in the world is reason for declaring the following in the class?:
sic> var $somevar;
sic> I see no reason, and no differences if I don't declare: var $somevar;
Classes are intended to be structured data storage. You sh
Hello,
class a {
var $somevar;
function b(){
if (!isset($this->somevar))
echo "Not set";
if (empty($this->somevar))
echo "empty";
}
}
$d = new a;
$d->b();
The above returns:
Not set
empty
What in the world is reason for declaring the following in th
10 matches
Mail list logo