View Full Version : Syntax Question: "->"
citricguy
12-29-2005, 01:35 AM
Ok, for the most part I understand this, but what exactly does the '->' do (in the code below)? I have had some trouble searching for it due to the length and charactors used :ermm:
// Question about this code:
if ($a== '' OR !$b->options['somthing'])
filburt1
12-29-2005, 01:37 AM
It references a field or method in an object. In this case, index "somthing" in the field "options" in the object "b."
http://www.php.net/oop
citricguy
12-29-2005, 02:02 AM
http://www.php.net/oop definatly helped, (Thank you!)
if($b->options['somthing']) {
}
So from that statement above...
'$b' is an entity in and of itself (a class?)
'options['somthing']' is defined within the object $b?
the proper way to reference 'options['somthing']' outside of the object '$b' is to use '$b->options['somthing']'?
filburt1
12-29-2005, 02:58 AM
$b is an object, which is an instance of a class. PHP doesn't have strong data types so there's no way of knowing by just looking at the code.
options is an array in $b, and you're referencing the key "somthing".
Yes, and inside the class, you have to use $this due to crappy scoping.
PHP has a broken, half-assed-implemented OOP model. If you really want to learn how OOP works, Java is the way to go.
citricguy
12-29-2005, 09:53 PM
Hey thanks for taking the time to help me through that. Looks like im gona take a crack at Java next.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.