I can't find the page for it atm, but it only supresses non-fatal errors (E_WARNING and E_NOTICE errors and E_STRICT in PHP5), if it is E_CORE_*, E_COMPILE_*, E_ERROR or E_PARSE error (all fatal errors), then you will still see an error message.
If @ is used in conjunction with include() or require() it will supress all error (even parse) from within the included files. In that case it is an absolute disastor waiting to happen... Apparently few realise just how messy that usage makes finding fatal bugs that are never reported or logged...
The results of the function are returned by reference, instead of copy.
only really applicable to arrays and objects and the only real functional use is for performance, but in PHP this is automanaged and is not necessary Razz
Referencing creates a "reference" to a variable. Basically you create something akin to a "bookmark" which points to the original variable. Without referencing in PHP4, every time you passed a variable to, or returned a variable from a function - it would be a copy. If you do a lot of each, or have very large variables (e.g. a data object) those copies will quickly eat up memory and effect performance. Worse, if you are trying to pass around just one object, and all changes are to be made to that object only - without references you'd end up with multiple copies, instead of the single completed object you wanted
Referencing in PHP5 is different - PHP5 already references all objects by default (a big difference from PHP4).
Summary - a reference is a "bookmark" to the original variable. Any changes to a reference, are applied to the original variable (wherever you initialised it).
For example:
Code: Select all
function addOne(&$foo) {
$foo = $foo +1; // the referenced var
}
$foo = 0; // the original var
addOne($foo);
echo $foo; // returns 1 (operation on a reference, changes the original variable)
The other side is returning by reference:
Code: Select all
function &createFoo() {
$foo = 0; // the original var
return $foo;
}
$foo_ref =& createFoo(); // $foo_ref is a reference to the $foo created INSIDE the function
// important when returning references to use =& not just =
Any q's fire away...
