CodeIgniter Forums
Only variables should be passed by reference - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Only variables should be passed by reference (/showthread.php?tid=64200)



Only variables should be passed by reference - dsflyerds - 01-26-2016

I get this error on my admin controller and I'm not sure how to fix it. 

Severity: Runtime Notice
Message: Only variables should be passed by reference
Filename: controllers/Admin.php
Line Number: 14

Line 14: 
PHP Code:
$section end($this->uri->segment_array()); 



RE: Only variables should be passed by reference - josepostiga - 01-26-2016

Check the PHP documentation about the end() function: http://php.net/manual/en/function.end.php

Quoting the parameters section:
Quote:array
The array. This array is passed by reference because it is modified by the function. This means you must pass it a real variable and not a function returning an array because only actual variables may be passed by reference.

Try this:
PHP Code:
$segments $this->uri->segment_array(); 

$section end($segments);