dgruetter Posted April 26, 2011 Share Posted April 26, 2011 I must admit, I do not know what this is used for. I just started oop with php and know what a -> does, but I see => being used all the time and I cannot find out it's exact meaning. Can someone shed a little light on this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/ Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 i know that => is commonly used to extract a value for a key in an array... $a = array( "one" => 1, "two" => 2, "three" => 3, "seventeen" => 17 ); foreach ($a as $k => $v) { echo "\$a[$k] => $v.\n"; } something like that Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206225 Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 where $v would be the values stored in the $k key of $a array Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206226 Share on other sites More sharing options...
hyster Posted April 26, 2011 Share Posted April 26, 2011 also as a condition > means greater than < means less than = means the same as so u can use =< means equal to or less than => means equal to or more than its a way of setting a dividing line example $a = '????'; $b = '10'; if ($a => $b) $answer = ''yes; else $answear = 'no'; if $a is less than 10 then $b returns 'no' if %a is 10 or more then $b returns 'yes' Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206268 Share on other sites More sharing options...
trq Posted April 26, 2011 Share Posted April 26, 2011 @hyster Greater than or equal to is represented by >= not => Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206280 Share on other sites More sharing options...
hyster Posted April 26, 2011 Share Posted April 26, 2011 oops. thanks thorpe. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206281 Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 I think it may also be used in objects along with -> bit I'm not sure Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206357 Share on other sites More sharing options...
trq Posted April 26, 2011 Share Posted April 26, 2011 I think it may also be used in objects along with -> bit I'm not sure Nope. It is a simple operator designed to assign values to array keys. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206371 Share on other sites More sharing options...
salathe Posted April 26, 2011 Share Posted April 26, 2011 The => operator is, perhaps confusingly, called a "double arrow" (the token name that PHP sees is T_DOUBLE_ARROW). It is used in two places, neither being anything directly related to objects or OOP. [*]When assigning keys to be associated with array values $fruits = array('a' => 'apple', 'b' => 'banana'); [*]When retrieving the key in a foreach loop foreach ($fruits as $key => $value) { Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206410 Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 so basically the two the I described yesterday Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206414 Share on other sites More sharing options...
salathe Posted April 26, 2011 Share Posted April 26, 2011 so basically the two the I described yesterday Absolutely, just without the uncertainty. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206483 Share on other sites More sharing options...
chaseman Posted April 26, 2011 Share Posted April 26, 2011 The => operator is, perhaps confusingly, called a "double arrow" (the token name that PHP sees is T_DOUBLE_ARROW). It is used in two places, neither being anything directly related to objects or OOP. [*]When assigning keys to be associated with array values $fruits = array('a' => 'apple', 'b' => 'banana'); [*]When retrieving the key in a foreach loop foreach ($fruits as $key => $value) { Very defined formulation! How would you define -> ? When using for example $this->post_id I know how to use it but I don't really know how to define or explain it to somebody, and I think that shows that I don't fully understand it. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206492 Share on other sites More sharing options...
salathe Posted April 26, 2011 Share Posted April 26, 2011 Very defined formulation! How would you define -> ? That is the "object operator" or, more colloquially, the "arrow operator". Its token name when PHP parses your code into pieces is T_OBJECT_OPERATOR. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206493 Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 salathe copy paste from php.net Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206529 Share on other sites More sharing options...
Pikachu2000 Posted April 26, 2011 Share Posted April 26, 2011 Yeah, well there's a good chance that salathe may have actually written that part of the manual. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206530 Share on other sites More sharing options...
fugix Posted April 26, 2011 Share Posted April 26, 2011 cool Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206531 Share on other sites More sharing options...
chaseman Posted April 26, 2011 Share Posted April 26, 2011 Very defined formulation! How would you define -> ? That is the "object operator" or, more colloquially, the "arrow operator". Its token name when PHP parses your code into pieces is T_OBJECT_OPERATOR. And in which situations exactly is it used? Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206539 Share on other sites More sharing options...
wildteen88 Posted April 26, 2011 Share Posted April 26, 2011 Very defined formulation! How would you define -> ? That is the "object operator" or, more colloquially, the "arrow operator". Its token name when PHP parses your code into pieces is T_OBJECT_OPERATOR. And in which situations exactly is it used? When you're using/assigning an objects properties/methods. Its all in the manual. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206606 Share on other sites More sharing options...
salathe Posted April 26, 2011 Share Posted April 26, 2011 salathe copy paste from php.net Not at all, though I do know the manual inside out. Yeah, well there's a good chance that salathe may have actually written that part of the manual. Not that particular part. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206614 Share on other sites More sharing options...
fugix Posted April 27, 2011 Share Posted April 27, 2011 sorry salathe..was rude of me Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206693 Share on other sites More sharing options...
salathe Posted April 27, 2011 Share Posted April 27, 2011 sorry salathe..was rude of me Not a problem, I didn't consider it rude at all. But thanks for the apology. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1206756 Share on other sites More sharing options...
dgruetter Posted April 28, 2011 Author Share Posted April 28, 2011 Thank you very much for the information. IT was very helpful. Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1207299 Share on other sites More sharing options...
fugix Posted April 28, 2011 Share Posted April 28, 2011 glad we could help! Quote Link to comment https://forums.phpfreaks.com/topic/234725-what-does-mean/#findComment-1207310 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.