|
-
Feb 11th, 2006, 12:39 PM
#1
Thread Starter
Addicted Member
Special purpose of ->
Languages like vb,java, and .net.DOT operator is used to access class functions but in php -> operator is used.What is its speciality?
-
Feb 11th, 2006, 12:49 PM
#2
<?="Moderator"?>
Re: Special purpose of ->
Well in PHP the . (period) is used to join variables. Much like + in other langauges. Also i think that it is because PHP has take syntax from C++ and thats how class members are refered too.
-
Feb 11th, 2006, 12:57 PM
#3
Thread Starter
Addicted Member
Re: Special purpose of ->
But i think in C++ .operator isn't used?
-
Feb 11th, 2006, 01:03 PM
#4
<?="Moderator"?>
Re: Special purpose of ->
 Originally Posted by slice
But i think in C++ .operator isn't used?
Both . and -> are used, ones for when the class is a pointer i think. It been ages since used C++. Back on topic, as far as i know its just to save confusion between a class method and adding variables. If you want to know more about OOP in PHP read the announcement at the top of the forum, and visualAds PHP 5 OOP tutorial
-
Feb 11th, 2006, 02:40 PM
#5
Re: Special purpose of ->
The reason that . wasn't used is simply that it was already taken. (Perl legacy.)
The reason that -> was chosen as replacement is that it is used in C and C++.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 12th, 2006, 11:27 PM
#6
Frenzied Member
Re: Special purpose of ->
slice:
in php -> operator is used.What is its speciality?
the symbols (->) are used to access Class Members.
If you have already defined a class (for example: TextBox) you can make
an instance of it using the keyword (new) and then use it, like so:
$box = new TextBoxSimple;
$box->display();
The result of evaluating this code will be to print an HTML fragment
containing a table definition enclosing the text my text.
(Not especially useful, but it’s a start.)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|