quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
can the class itself have parameters that are passed upon instantiating? so dbConnection(param1) for example?
Yes. You can redefine the param list for any constructor in a hierarichy. If you do, you are responsible, of course, for correctly calling your parent.
quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
is the double underscore in the var declarations anything special? or just a convention on perks part.
The "$doConnect=true" parameter in the dbconnect function. Is that a default for in case that parameter is not passed?
There are a bunch of magic functions... __construct __destruct, __get __set, __isset, __unset, __call, __autoload, __sleep, __wakeup and __clone. I'll leave it to you to figger out which does what... but in this case, the __ is
PHP
's convention. I have, however, taken to personally use this same convention for things that I want to remember as "magic."
quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
$this refers to the function or the class? im guessing class.
Zactly - the self-instance reference
quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
function &cloneConnection() errrr whats the & for?
return a reference rather than a value... in that case, I am returning a reference to an object that is created in that function.
quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
is there no concept of public and private methods in
php
classes?
Not in
PHP
4, but in
PHP
5 there is private, protected and public. There are still a few providers out there that use 4.3.4 (the earliest version that is really still viable) but anyone worth there salt has been into 5 for a couple years.
quote author=nutballs link=topic=501.msg3272#msg3272 date=1189814058
are there no properties in
php
classes? are the class level vars basically like properties in other languages?
Properties in a
PHP
class are simply variable references. To have an exposed property you'd do this:
class myclass
{
private $var1;
protected $var2;
public $var3;
}
... in that instance, you can talk to $var 3 but not 1 or 2. IMPORTANT: I could easily do this:
$anObj->aVariableThatWasNeverDefined = true;
this is completely valid. The new variable will be attached to <that> instance of the class and you can use it in a read/write way. I think this sucks. This means that you can misspell a var while assigning it to an object and never know that THAT's the reason things don't work later.
The way to get around this is to use the __get and __set magic funcs - with these you can trap all of the getting and setting of vars against $this. Using this functionality, you can replicate normal class events and "do stuff" on the setting of a variable, or prevent the getting of one... or ... well, you know.