View Full Version : PHP question
inenigma
06-05-2010, 10:43 PM
Hi,
I've gone thru the PHP Tutorial on W3 and I've not seen reference to things such as
"$vbulletin->GPC['moderatorid']". Can anyone tell me what this operator (->) does ??
Mr Happy
06-06-2010, 12:41 AM
I'm not the best at explaining but these are sorta custom vBulletin commands.
-> sorta means this or next
So in the example you gave it's vbulletin this GCP
GCP is like a clean function so it's cleaning the contents of moderatorid
moderatorid is a varable which in this case is a number and represents the id number.
So the line you gave means "vBulletin this clean moderatorid"
Hope you follow me. As I said I'm not the best at explaining this sorta stuff.
consolegaming
06-06-2010, 12:50 AM
I'm not sure what the technical term for it is but it's used for PHP's OOP (object-oriented programming). $vbulletin is a class and to access that classes members (variables of the class) or functions you can use the -> operator. So that just means that GPC['moderatorid'] is a member of the $vbulletin class. Quite a few programming languages use the same operator for this purpose.
EDIT: Posted this before seeing Happy's response. I'm not really sure that's a valid response. I don't know much about vBulletin itself/their functions etc but as far as I can tell the GPC there isn't a function it's just an array. I'm presuming this clean function that you mention sets this array up though. Plus I certainly weren't aware of -> being a custom vB command lol. It's part of PHP's programming language.
Mr Happy
06-06-2010, 01:20 AM
Sorry I know that is -> OOP isn't custom to vBulletin. I was refering to the whole $vbulletin->GPC command. As I said I'm not great at explaining things and was trying to explain it in simple English. If inenigma was using W3schools for tutorials I presumed he wanted it in an extremely simple English explanation. Sorry.
inenigma
06-06-2010, 06:58 AM
I'm not sure what the technical term for it is but it's used for PHP's OOP (object-oriented programming). $vbulletin is a class and to access that classes members (variables of the class) or functions you can use the -> operator. So that just means that GPC['moderatorid'] is a member of the $vbulletin class. Quite a few programming languages use the same operator for this purpose.
Cool. I can understand that. Is there a reference manual anywhere that would have all of the vBulletin classes and functions as I can see the "->" operator used all over the place in the code. I've got a good grounding in programming and want to learn PHP so I thought I'd buy vBulletin as investment in my education. If I can understand what the code is doing, then I can make changes to it...
Guest190829
06-06-2010, 07:30 AM
API documentation is available through the member control panel at
http://members.vbulletin.com/api/index.html
Attilitus
06-06-2010, 07:44 AM
Cool. I can understand that. Is there a reference manual anywhere that would have all of the vBulletin classes and functions as I can see the "->" operator used all over the place in the code. I've got a good grounding in programming and want to learn PHP so I thought I'd buy vBulletin as investment in my education. If I can understand what the code is doing, then I can make changes to it...
-> is the equivalent of the dot operator in Java for accessing the methods and variables stored in an instance of a class.
James Birkett
06-06-2010, 12:14 PM
If you had a database class that contained functions to do with a database (I'm not going to write it).
Your class is $db.
1 function is clean() to sanitise inputs for databases.
1 function is insert() to insert inputs into the database.
1 function is select() to select from the database.
Now, because these are contained in the $db class, we can access these functions as a child property of that class, by using the (->) operator.
$db->clean($_POST['somestuff']);
$db->insert($_POST['somestuff']);
I'm sorry if that didn't help, as Attilitus said it's used to access methods and variables that are stored inside your class.
inenigma
06-06-2010, 06:29 PM
-> is the equivalent of the dot operator in Java for accessing the methods and variables stored in an instance of a class.
Cool. Understand now. I'm new to PHP and had not seen reference to -> in any of the doco that I'd read and wanted to understand what it was doing.
Thanks Guys
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.