Some Newbie Questions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trent2800
Forum Commoner
Posts: 48
Joined: Mon Oct 02, 2006 7:02 am

Some Newbie Questions

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Re: Some Newbie Questions

Post 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
Post Reply