vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   PHP question (https://vborg.vbsupport.ru/showthread.php?t=244021)

inenigma 06-05-2010 10:43 PM

PHP question
 
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

Quote:

Originally Posted by consolegaming (Post 2049016)
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

Quote:

Originally Posted by inenigma (Post 2049133)
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

Quote:

Originally Posted by Attilitus (Post 2049144)
-> 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


All times are GMT. The time now is 07:24 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01199 seconds
  • Memory Usage 1,732KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete