Languages like vb,java, and .net.DOT operator is used to access class functions but in php -> operator is used.What is its speciality?
Printable View
Languages like vb,java, and .net.DOT operator is used to access class functions but in php -> operator is used.What is its speciality?
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.
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 tutorialQuote:
Originally Posted by slice
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++.
slice:
the symbols (->) are used to access Class Members.Quote:
in php -> operator is used.What is its speciality?
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.)