vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Syntax Question: "->" (https://vborg.vbsupport.ru/showthread.php?t=103935)

citricguy 12-29-2005 01:35 AM

Syntax Question: "->"
 
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:

PHP Code:

// 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!)

PHP Code:

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.


All times are GMT. The time now is 06:35 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.01008 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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