I am using CodeIgniter and I have a problem the code very simple just few row in the controller ,this is my controller
<?php
class Site extends Controller {
function index() {
echo 'i am here';
}
}
And this are the errors:
1- Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci\system\codeigniter\Common.php on line 130
2-Deprecated: Assigning the return value of new by reference is deprecated in C:\wamp\www\ci\system\codeigniter\Common.php on line 136
3-A PHP Error was encountered
Severity: 8192
Message: Assigning the return value of new by reference is deprecated
Filename: libraries/Loader.php
Line Number: 255
4-A PHP Error was encountered
Severity: 8192
Message: Assigning the return value of new by reference is deprecated
Filename: database/DB.php
Line Number: 133
I don't know where is the problem, certainly the code is correct but where is the problem. Any suggestions?
&
is used in PHP to pass an object to a method / assign a new object to a variable by reference. It is deprecated in PHP 5 because PHP5 passes all objects by reference, but other vars default to by value.
To fix this error:
Update to the latest version of CodeIgniter, really!
Recently I faced the same prob, I was using codeigniter 1.7 and PHP 5.2.6 everything was working great, but after upgrading PHP to 5.3 the below error starts coming:-
Deprecated: Assigning the return value of new by reference is deprecated
The reason behind it is same as mentioned by @Amal , & is used in PHP to pass an object to a method / assign a new object to a variable by reference. It is deprecated in PHP 5 because PHP5 passes all objects by reference
For more info Refer to
Assigning the return value of new by reference is deprecated
So if you are creating your code from scratch, then better to use all the latest things, use codeigniter 2.1.4
But if you have your codebase in some old codeigniter version, then better to degrade your PHP (which is not recommended) till the time you move on to newer version.