Page 1 of 1

Static or public functions inside a class

Posted: Wed Apr 25, 2007 10:32 am
by Smasher
Can anyone define the difference? I cant seem to produce any different results between using the two.

Posted: Wed Apr 25, 2007 10:35 am
by aaronhall

Posted: Wed Apr 25, 2007 10:47 am
by Smasher
Okay so

static is essentially used for functions inside a class that will be called on there own without an instance of the class
static can be put before both public and private.

public are functions that can access anything within the class
private are for functions or vars within the class that cant be called from anywhere but within that class

Thanks.

Posted: Wed Apr 25, 2007 10:50 am
by aaronhall
Exactly, only the static keyword is placed after the visibility keyword

Code: Select all

public static function funcName() {
edit: oops, forgot "function" (thanks d11)

Posted: Wed Apr 25, 2007 11:10 am
by Chris Corbyn
Yes, ordering goes:

[final|abstract] [public|private|protected|var] [static] [function|$]name