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

0 Members and 1 Guest are viewing this topic.

Offline JC99Topic starter

  • Irregular
  • Posts: 18
    • 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
  • Posts: 175
  • 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

  • Addict
  • Posts: 2,646
  • Gender: Male
  • Programming, the art of combining math and logic.
    • 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
Why is hashing a hash bad practice?
Quote from: Zane
A business person’s best customers are always using the cheapest piece of shit computer out there. I don’t have the sources to back it up, but I’d like to say it’s a proven fact.
Quote from: requinix
Use objects when they make sense and functions when they don't.
Crikey Games Pty Ltd | Realm Battles Classic
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
  • Posts: 18
    • 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 Alex

  • Global Moderator
  • Addict
  • *
  • Posts: 2,487
  • 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();
:anim_rules: Read the rules, :rtfm: and don't forget to use [code] / [php] tags!


Offline JC99Topic starter

  • Irregular
  • Posts: 18
    • 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 Alex

  • Global Moderator
  • Addict
  • *
  • Posts: 2,487
  • 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.
:anim_rules: Read the rules, :rtfm: and don't forget to use [code] / [php] tags!


Offline JC99Topic starter

  • Irregular
  • Posts: 18
    • 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 Alex

  • Global Moderator
  • Addict
  • *
  • Posts: 2,487
  • 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.
:anim_rules: Read the rules, :rtfm: and don't forget to use [code] / [php] tags!