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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

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

    hi experts,

    i am new to php, i am confused with these syntax in codings, kindly explain me this with example.
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    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:

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      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($MyArra y 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

      Comment

      • nirmalsingh
        New Member
        • Sep 2006
        • 218

        #4
        Originally posted by Atli
        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($MyArra y 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.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          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:
          Code:
          $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:

          Comment

          Working...