Possible Duplicate:
Reference - What does this symbol mean in PHP?
I've seen in PHP some variables that are set like this:
$var = @$something;
Or functions set like this:
$var = &my_function();
What effect do the @ and the & have?
Possible Duplicate:
Reference - What does this symbol mean in PHP?
I've seen in PHP some variables that are set like this:
$var = @$something;
Or functions set like this:
$var = &my_function();
What effect do the @ and the & have?
You have them backwards. &$variable
means "a reference to this variable." @my_function()
means "call this function and suppress any errors or warnings that it produces."
@ means "don't report errors"
& means "take a reference to the following variable instead of copying its value"
@
operator in php is used to ignore errors in that statement.
Manual: http://www.php.net/manual/en/language.operators.errorcontrol.php
&
is reference operator.
Manual: http://www.php.net/manual/en/language.references.whatdo.php
@
causes to hide all errors. In case of variables, it might be E_NOTICE informing about variable not existing.
The &my_function();
is invalid - &
is normally used for references, it doesn't nothing in this case.