im new to PHP and i have come across two ways that people declare their functions parameters.
function fun(array &$array)
{
return $stuff
}
OR
function fun($array)
{
return $stuff
}
From what i read in the documentation the &
passes the reference to the variable. but i thought that declaring the type array
was unnecessary.
So, when i pass reference to a variable in a function is declaring its variable type optional?
Meaning is function fun(array &$array)
AND function fun(&$array)
equivalent/allowed?