GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP programmers in here please! (https://gfy.com/showthread.php?t=936296)

ro8in 10-31-2009 02:59 PM

PHP programmers in here please!
 
if I had a class lets say

class myclass {
function myfunction() {

}
}

Why in the world would I do

$myclass = new myclass

and use the function as
$myclass->myfunction

while I can forget all that and just do

myclass::myfunction()


what can be a possible reason not to use the double colon way??

i can't think of any...

woj 10-31-2009 03:06 PM

the point of classes isn't so you can put functions inside of them...

the point is that you create objects, which have certain properties, and you make them do stuff by calling certain methods...

ro8in 10-31-2009 03:15 PM

thanks for your reply

I get it now

using :: is just static

while the other way I could do

$myclass1 = new myclass("yourname")
$myclass2 = new myclass("myname")

then $myclass1 and $myclass2 would refer to the same class but have different properties..

intresting stuff....

but why php can only extend one class?

redwhiteandblue 10-31-2009 04:16 PM

Quote:

Originally Posted by ro8in (Post 16488357)
intresting stuff....

but why php can only extend one class?

PHP doesn't support multiple inheritance if that's what you mean. But you can derive a class from another class that is derived from another class and so on.


All times are GMT -7. The time now is 12:44 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123