Static or public functions inside a class
Moderator: General Moderators
Static or public functions inside a class
Can anyone define the difference? I cant seem to produce any different results between using the two.
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
You're talking apples and oranges -- check out http://www.php.net/manual/en/language.o ... bility.php and http://www.php.net/manual/en/language.oop5.static.php
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.
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.
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Exactly, only the static keyword is placed after the visibility keyword
edit: oops, forgot "function" (thanks d11)
Code: Select all
public static function funcName() {
Last edited by aaronhall on Wed Apr 25, 2007 11:42 am, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia