Page 1 of 1

Some Newbie Questions

Posted: Mon Oct 02, 2006 7:06 am
by trent2800
I've been dabbling in PHP for a while now and after pages and pages of documentation, I still have a couple lingering questions.

1) What is => used for exactly? I know that -> is for properties of classes but I haven't grasped => yet.


2) What is the function of //echo "Whatever" ? // represents a comment right?

Any and all assistance would be appreciated, thanks.

Re: Some Newbie Questions

Posted: Mon Oct 02, 2006 7:35 am
by twigletmac
trent2800 wrote:1) What is => used for exactly? I know that -> is for properties of classes but I haven't grasped => yet.
It's used in a few places, when assigning values to keys in arrays, e.g.:

Code: Select all

$my_array = array(
    'key1' => 'value1',
    'key2' => 'value2'
);
and in foreach loops, e.g.

Code: Select all

foreach ($my_array as $key => $value) {
    echo $key.': '.$value;
}
trent2800 wrote:2) What is the function of //echo "Whatever" ? // represents a comment right?
// does start a comment so

Code: Select all

// echo 'whatever';
would just be a commented out echo statement so wouldn't do anything.

Mac