Author Topic: What do these mean?  (Read 221 times)

0 Members and 1 Guest are viewing this topic.

Offline JC99Topic starter

  • Irregular
    • View Profile
What do these mean?
« on: June 26, 2009, 12:57:42 AM »
Hey all, I'm new to these forums and have decided to learn PHP.  I have 2 questions.

What does => mean?
What does -> mean?

I bought the book "Programming PHP" published by O'Reilly and was just flipping through it but I can't find the definition of -> and => in the book even though they are used in code examples throughout the book. Can someone explain these two things to me.

Thanks

Offline Eggzorcist

  • Enthusiast
  • Gender: Male
  • The Haunted Egg Arises
    • View Profile
Re: What do these mean?
« Reply #1 on: June 26, 2009, 01:46:19 AM »
The expression "=>" that's normally used in some-kind of if statement. and it means for example


$variable1 => $variable2

which means varriable2 is either equal or less than variable1.

The expression "->" looks like object oriented programming to me but I could be wrong. I don't use OOP normally. But in OOP it goes after a variable for example " $variable->status" But I could be wrong but I'm certain about the first one.
PHP SQL programming - Macbook Pro - MAMP User

Offline MasterACE14

  • Supporter
  • Addict
  • *
  • Gender: Male
  • Reverse your World.
    • View Profile
    • Crikey Games Pty Ltd
Re: What do these mean?
« Reply #2 on: June 26, 2009, 01:50:42 AM »
The expression "=>" that's normally used in some-kind of if statement.


In a if it is used like >= (equal to or greater than)

It is generally used in arrays and loops.
$key => $val
Crikey Games Pty Ltd | Realm Battles | Conflicting Forces in development...

It's too big a world to be in competition with everyone.  The only person who I have to be better than is myself. ~Harry Morgan

Offline JC99Topic starter

  • Irregular
    • View Profile
Re: What do these mean?
« Reply #3 on: June 26, 2009, 01:51:21 AM »
I thought "equal to or less than" was <=
and that "equal or greater than" was >=

I wanted to know about =>

Offline AlexWD

  • Guru
  • Devotee
  • *
  • Gender: Male
  • < 1 billion
    • View Profile
Re: What do these mean?
« Reply #4 on: June 26, 2009, 01:53:51 AM »
I thought "equal to or less than" was <=
and that "equal or greater than" was >=

I wanted to know about =>

They pretty much covered it. => in arrays key => value.

-> Is used (not only in PHP) as a pointer. Example: class->method();

Offline JC99Topic starter

  • Irregular
    • View Profile
Re: What do these mean?
« Reply #5 on: June 26, 2009, 01:59:35 AM »
I guess I have to read up on arrays and classes.

Thanks guys

Offline AlexWD

  • Guru
  • Devotee
  • *
  • Gender: Male
  • < 1 billion
    • View Profile
Re: What do these mean?
« Reply #6 on: June 26, 2009, 02:06:36 AM »
I guess I have to read up on arrays and classes.

Thanks guys

Here's a little bit of a better explanation:

$array = Array('something' => 'value');
echo 
$array['something']; // 'value'


Key => Value, Key is the name by which you'll be accessing that element of the array. And the value is well, the value of that element.

Offline JC99Topic starter

  • Irregular
    • View Profile
Re: What do these mean?
« Reply #7 on: June 26, 2009, 02:17:47 AM »
The expression "=>" that's normally used in some-kind of if statement. and it means for example


$variable1 => $variable2

which means varriable2 is either equal or less than variable1.


I am a little confused. So does this mean >= and => are interchangeable?
« Last Edit: June 26, 2009, 02:20:13 AM by JC99 »

Offline AlexWD

  • Guru
  • Devotee
  • *
  • Gender: Male
  • < 1 billion
    • View Profile
Re: What do these mean?
« Reply #8 on: June 26, 2009, 02:28:38 AM »
The expression "=>" that's normally used in some-kind of if statement. and it means for example


$variable1 => $variable2

which means varriable2 is either equal or less than variable1.


I am a little confused. So does this mean >= and => are interchangeable?


No, => is used in arrays. >= would be used in a conditional statement.

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.