TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-24-2009, 01:23 PM   #1 (permalink)
The Visitor
 
Join Date: Oct 2009
Posts: 4
Thanks: 0
drago is on a distinguished road
Default Hello

Hello to everybody. I saw that is a "tradition" that new members do here a very short presentation. So I start saying that my native language is not english so I apoligize for gramatical and exprimal mistakes.

I am relative new in php and I search for information in this domain. A problem that i have is with the OOP. I dont know how to use the "::" operator.I have some big books with php but neither one covers this operator. I saw in some joomla code that it's use without creating an object. The "->" is in every book. Thanks
drago is offline  
Reply With Quote
Old 10-24-2009, 03:54 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

welcome aboard!
a simple explanation the :: operator addresses static methods or constant properties inside a class without the need to make an instance of the class
tony is offline  
Reply With Quote
Old 10-24-2009, 07:07 PM   #3 (permalink)
The Visitor
 
Join Date: Oct 2009
Posts: 4
Thanks: 0
drago is on a distinguished road
Default

Thanks. This is a problem that i search explanation for some time.
drago is offline  
Reply With Quote
Old 10-26-2009, 01:18 PM   #4 (permalink)
Jim
The Addict
 
Jim's Avatar
 
Join Date: Nov 2007
Location: the Netherlands
Posts: 281
Thanks: 2
Jim is on a distinguished road
Default

Ill try to explain quickly:

The use of :: is when you want to call a method of a class directly. You use -> on an object of a class.

An object is een instance of a class (e.g. $obj = new ClassName();) this means that the object is a piece that inheritted all kinds of properties and methods from the class. The class is the blueprint for the object. When you want to access the method from the object, you use $obj->myMethod(). What myMethod does all depents how the blueprint (class) looks like.

Now the :: operator removes the whole instance class, with it you can skip it all and access the method directly. The only downside is that your method wont be able to use the $this property.

Calling a method via :: is called a static call. (In many other languages, you first have to declare your function static before you are able to call it on a static way)
__________________
Nunchaku! Who doesn't like martial arts? =)
Send a message via MSN to Jim Send a message via Skype™ to Jim
Jim is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:32 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design