You are here: Re: can i have an array as a class variable? « PHP Programming Language « IT news, forums, messages
Re: can i have an array as a class variable?

Posted by Kimmo Laine on 10/21/23 11:57

"Slant" <rcross@gmail.com> wrote in message
news:1157476551.134715.190600@d34g2000cwd.googlegroups.com...
> I see no reason why this should not work. In a recent post here in
> this same group, I posted a very similar example for a Database
> instantiation class:
>
> function __construct() {
>
> $db['host'] = "localhost";
> $db['user'] = "root";
> $db['pass'] = "";
> $db['name'] = "pbtportal";
>
> $link = mysql_connect($db['host'],$db['user'],$db['pass']);
> mysql_select_db($db['name'],$link);
>
> }
>
> Works like a charm! In this case, I did not declair the variable "$db"
> but probably should have.

IMHO, those aren't class members, the $db elements. You should be using the
$this pointer: $this->db[...]. Now they're only visible inside the scope of
the __construct method. This is't exactly the same thing that nephish was
asking...

Still, the way nephish was doing it works fine, your example just doesn't
demonstrate it very well.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti pδivittyvδ nettisarjis
spam@outolempi.net || Gedoon-S @ IRCnet || rot13(xvzzb@bhgbyrzcv.arg)

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация