On 3/22/06, Michael Hulse <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am just learning about classes.
>
> My server is running PHP 4.3.11
>
> Example code:
>
> class testing {
>         var $what;
> }
>
> $linkGenClass = new testing();
> $linkGenClass->what = 'hi';
> echo $linkGenClass->what;
>
> Why does the constructor require the "()"?

You're calling a method (which is a function inside a class). You
can't call a regular function without the brackets, so methods should
be the same.

> I have seen many examples via google that do not use "()".

It's better to use them mainly because it's the standard way (c#,
java, c++ all make you use them so better to get into the habit now).

> Should I worry about capitalizing the first letter of the class?

Personal preference. You don't need to.

> Can class names have underscores?

Yes.

> Are spaces allowed on either side of the "->"?

Try it and see what happens :)

> Is "var $what" PHP 4 and 5, whereas "public $what" is PHP 5?

Yes.

Public means you can do:

$linkGenClass->what = 'hi';

private means you can't access it that way.

> Got any good links to class tutorials for PHP 4.3.11?

Shameless plug for my own site :P
http://www.designmagick.com/article/18/PHP/Introduction-to-Object-Oriented-Programming

Other sites:
http://www.phpbuilder.com/columns/luis20000420.php3
http://www.onlamp.com/pub/a/php/2002/07/18/php_foundations.html

> Sorry to sound like a PHP noob.

We all started somewhere :)

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to