By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,824 Members | 1,279 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,824 IT Pros & Developers. It's quick & easy.

what is difference between ->, =>,<=,<- ?

nirmalsingh
100+
P: 218
hi experts,

i am new to php, i am confused with these syntax in codings, kindly explain me this with example.
Jan 30 '07 #1
Share this Question
Share on Google+
4 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Where did you find these? <= and <-
Besides, since you are already using command $t->set_block in an earlier thread, I can assume that you know what you have been coding.
Also, I will not hurry to reply.

Ronald :cool:
Jan 30 '07 #2

Atli
Expert 5K+
P: 5,058
I've never come across <- before, not sure if it even exists.

But the -> is used with classes. Simular to C++'s class::func or C#'s class.func, in php its like this:

[PHP]
$Myclass -> MyFunction()
$Myclass -> MyVariable;[/PHP]
The => and <= are mostly used in boolean statments, like if statments or loops,
Few examples:

[PHP]if(0 => 1){} // Greater or equal to, evaluates true in this case.

for($x=0; $x <= 10; $x++){} // Less or equal to, runs 11 times[/PHP]

=> is also used with foreach() statments where you want the use the loop index.
That is:

[PHP]foreach($MyArray as $x => $var){}
// $x is the index, $var is the value [/PHP]

I cant remeber any more at the moment :P

Hope this answers your question
Jan 31 '07 #3

nirmalsingh
100+
P: 218
I've never come across <- before, not sure if it even exists.

But the -> is used with classes. Simular to C++'s class::func or C#'s class.func, in php its like this:

[PHP]
$Myclass -> MyFunction()
$Myclass -> MyVariable;[/PHP]
The => and <= are mostly used in boolean statments, like if statments or loops,
Few examples:

[PHP]if(0 => 1){} // Greater or equal to, evaluates true in this case.

for($x=0; $x <= 10; $x++){} // Less or equal to, runs 11 times[/PHP]

=> is also used with foreach() statments where you want the use the loop index.
That is:

[PHP]foreach($MyArray as $x => $var){}
// $x is the index, $var is the value [/PHP]

I cant remeber any more at the moment :P

Hope this answers your question
that wat i needed thank u atli.
Jan 31 '07 #4

ronverdonk
Expert 2.5K+
P: 4,258
As an add-on:
=> is, besides its use as a comparison operator in 'equal or lower then') also used in arrays to assign a key to a value. That is what the foreach in the previous post also does. It is not a foreach rule, but distinguishing a key and its value, such as in statement:
Expand|Select|Wrap|Line Numbers
  1. $array = array('abc' => 'def', '0' => 'value');
where 'abc' and '0' are the keys in the array and 'def' and 'value' are their values.

Ronald :cool:
Jan 31 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.