Re: Really basic question



alan wrote:
Sorry that this is so simple -

Exactly what does the operator '=>' do?

Why can't I find it in the list of operators in the PHP manual?

And while I'm here, what about '->'? (I can't find that either)


=> is used to assign a value to an element in an array

For example:

$foo = array( 'one' => 1, 'two' => two, 'fred' => 'wilma');

-> is used to reference an element in a class (I use the word 'element' since it may be a function (method) or instance value (variable).

For example:

class Foo {
function splat() {
echo 'splat\n';
}
}

$foo = new Foo();
$foo->splat(); // causes 'splat' to be displayed.

-david-

.