Possible Duplicate:
Reference - What does this symbol mean in PHP?
What exactly does -> do in php?
I have a good understanding of the basics of php but never understood this. I tend to see in apps that use Codeignitor.
Possible Duplicate:
Reference - What does this symbol mean in PHP?
What exactly does -> do in php?
I have a good understanding of the basics of php but never understood this. I tend to see in apps that use Codeignitor.
It accesses accessible child methods or properties of objects:
class myClass {
public $fizz = 'Buzz';
public function foo() {
echo 'Bar';
}
}
$myclass = new myClass();
$myclass->foo(); // outputs 'bar'
$myclass->fizz = 'Not Buzz'; // overwrites $fizz value
I'm sure theres a more technical explanation but that is used to access properties and methods of an object.
Its basically the equivalent to the .
in javascript. The both acess an Objects properties/methods.
The biggest difference is that in PHP only class
es are Objects. While in JavaScript everything is an Object.
Therefore you can't do "string"->method()
in php while you can do the equivalent in JavaScript "string".method()
.
-> is accessing a varible inside of a class, so that
$class->variableInClass
It also can work with functions, with the same syntax as above.
If you're not familiar with OOP, I'd suggest looking here
Well I would razz you a bit because this is a very common operator. However it's very difficult to google for, so I understand.
This is a class access operator. It allows you to access members and functions of a class. So for example if I have a class named A with a member x, I could access it like this:
$a = new A();
$a->x;