Ask a Question related to PHP Development, Design and Development.
-
lawrence #1
Re: in object, declare array values at start or in constructor?
Zurab Davitiani <agt@mindless.com> wrote in message news:<2e9Ka.1807
Whoa!!! Thanks for that. I did follow the link and read what it says.>> > Thanks for the response. Why should I do it this way? My second
> > example works well and saves one line of code. What is the advantage
> > of declaring $config an array in the constructor? What's wrong with
> > var config = array()?
> Because of 2 reasons:
>
> 1. You are not using $this-> to refer to class properties; this is required.
> 2. The way which you described is not guaranteed to work in other/all
> releases; you should instead follow the link I gave in the previous
> response and do it as it is suggested in the documentation.
I have to rewrite all of my classes now. Sometimes I think PHP would
be better if it was less tolerant of mistakes.
lawrence Guest
-
#38536 [Asn->Csd]: Returning an array of values instead of an object
ID: 38536 Updated by: dmitry@php.net Reported By: sabrina at corp dot grupos dot com dot br -Status: Assigned... -
#38536 [Com]: Returning an array of values instead of an object
ID: 38536 Comment by: marcus at corp dot grupos dot com dot br Reported By: sabrina at corp dot grupos dot com dot br... -
#38536 [Opn->Asn]: Returning an array of values instead of an object
ID: 38536 Updated by: dmitry@php.net Reported By: sabrina at corp dot grupos dot com dot br -Status: Open... -
#38536 [NoF->Opn]: Returning an array of values instead of an object
ID: 38536 User updated by: sabrina at corp dot grupos dot com dot br Reported By: sabrina at corp dot grupos dot com dot br... -
#39242 [NEW]: Cannot declare a static array with an index
From: z_rules55 at hotmail dot com Operating system: WinXP PHP version: 5.1.6 PHP Bug Type: Class/Object related Bug...



Reply With Quote

