I have recently started working with PHP by getting into PHPBB3. The logic isn't too bad going thru the code (I am familiar with C and VB) but I cannot find any definitions for items like =>, ->, {SOME_TEXT}. They are used often, by the placement and context the appear to have some good uses, I just can't find any references on how. I'm dissapointed to find that search engines cannot find => or -> on sites. Any help would be fantastic! Thanks, John
-> is used with objects. Can check here: http://www.php.net/manual/en/language.oop5.basic.php Will add the :: to your list but it can wait. => is arrays. Manual page : http://us.php.net/manual/en/function.array.php the {} could be different things, phrase with some results is ... Complex (curly) syntax Strings page has some examples(have to scroll down or search for that phrase). http://us3.php.net/types.string
The curly brackets {} can be used at: function / class function name() { } PHP: if-else statement if (what) { } else { // !what } PHP: loop for () { } foreach () { } while () { } PHP:
The examples below show where my interest in the curly brackets is coming from, trying to figure this out. This if from an index.php file: // Assign index specific vars $template->assign_vars(array( 'TOTAL_POSTS' => sprintf($user->lang[$l_total_post_s], $total_posts), 'TOTAL_TOPICS' => sprintf($user->lang[$l_total_topic_s], $total_topics), 'TOTAL_USERS' => sprintf($user->lang[$l_total_user_s], $total_users), 'NEWEST_USER' => sprintf($user->lang['NEWEST_USER'], get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])), .... similar code .... $template->set_filenames(array( 'body' => 'index_body.html') ); Code (markup): This is from the "index_body.html" file, referenced in "index.php" above <!-- IF NEWEST_USER --> <h3>{L_STATISTICS}</h3> <p>{TOTAL_POSTS} • {TOTAL_TOPICS} • {TOTAL_USERS} • {NEWEST_USER}</p> <!-- ENDIF --> <!-- INCLUDE overall_footer.html --> Code (markup): I'm looking for a definition of how things like {TOTAL_POSTS} is linked to 'TOTAL_POSTS'.
Here's all I could find to explain it. The nutshell is, they are assigned by the Template Object. Unfortunately it doesn't really explain how its done, just outlines what you have already noted. I'm making an assumption that the template engine is essentially looking for the {} and uses it to lookup the correct values. http://wiki.phpbb.com/Template.assign_vars This is the user friendly version of the above : http://www.phpbb.com/kb/article/phpbb2-template-tutorial/ Here's a list of phpbb2 template variables (might be out of date but still useful). http://www.jakob-persson.com/node/541
Not directly in with your question, but you'll be asking it soon enough // lets get some variables to play with $a = 'hello world'; $b = "hello world"; // same as $a but uses double quotes so PHP looks to see if there are any embedded variables in the string $c = "my test phrase is: $b"; $d = "my test phrase is: {$b}"; //explicitly tells PHP were the variable starts and stops $myArray = array('apple','pear','orange'); $e = "I would like an $myArray[0] please"; //won't work because PHP doesn't understand what to do with the array $f = "I would like an {$myArray[0]} please"; //will work because the {} tell PHP how to handle the variable PHP: