Fix Errors Whilst Using Referenced Functions
This function would return an error when called:
function &getAllElements ( ) {
if (is_array($this->data)) {
return $this->data;
}
return null;
}
The error would be something along the lines of:
"Only variable references should be returned by reference."
A quick and dirty way (and the only way I could figure out) is to set a variable with your null value and return that:
function &getAllElements ( ) {
if (is_array($this->data)) {
return $this->data;
}
$null = null;
return $null;
}
Written by Antony D'Andrea
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#