Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 06-05-2010, 10:43 PM
inenigma's Avatar
inenigma inenigma is offline
 
Join Date: Apr 2010
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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 ??
Reply With Quote
  #2  
Old 06-06-2010, 12:41 AM
Mr Happy Mr Happy is offline
 
Join Date: Aug 2009
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 06-06-2010, 12:50 AM
consolegaming consolegaming is offline
 
Join Date: Jan 2007
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 06-06-2010, 01:20 AM
Mr Happy Mr Happy is offline
 
Join Date: Aug 2009
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 06-06-2010, 06:58 AM
inenigma's Avatar
inenigma inenigma is offline
 
Join Date: Apr 2010
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by consolegaming View Post
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...
Reply With Quote
  #6  
Old 06-06-2010, 07:30 AM
Guest190829
Guest
 
Posts: n/a
Default

API documentation is available through the member control panel at

http://members.vbulletin.com/api/index.html
Reply With Quote
  #7  
Old 06-06-2010, 07:44 AM
Attilitus's Avatar
Attilitus Attilitus is offline
 
Join Date: Mar 2005
Posts: 393
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by inenigma View Post
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.
Reply With Quote
  #8  
Old 06-06-2010, 12:14 PM
James Birkett James Birkett is offline
 
Join Date: Jun 2009
Posts: 633
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 06-06-2010, 06:29 PM
inenigma's Avatar
inenigma inenigma is offline
 
Join Date: Apr 2010
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Attilitus View Post
-> 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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:15 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.04231 seconds
  • Memory Usage 2,232KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (8)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete