You are here: Re: Declare variable as superglobal? « PHP Programming Language « IT news, forums, messages
Re: Declare variable as superglobal?

Posted by Oliver Grδtz on 08/24/05 17:52

Super Mango schrieb:
> Great! The "define" did it.
>
> Any Idea for the cases that I want to use a variable after all (for
> counter or for mysql connection)?

Good you elaborate on that?

For example, I hide the connecting stuff from everyday code. Looks
something like this:

class MySQL
{
private static $connection=null;
protected static function connect()
{
if (self::$connection != null) return;
self::$connection=mysql_connect('bla','blah','bla');
// read from config...
}
public function query($sql)
{
self::connect();
return mysql_query(self::$connection,$sql);
}
}

In my everyday code I just have to

$result=MySQL::query('SELECT * FROM test');

No explicit connecting required. Of course you can go for functions but
I'm all for the OOP way (even if it's just static stuff like here).

AllOLLi

 

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

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