This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Call-time pass-by-reference has been deprecated;
function getLib($pfComponentType,$pfComponentCode,$componentCode)
{
if($temp=require_once($this->getConfig($pfComponentType,$pfComponentCode,'librariesPath').$componentCode.'.php'))
{
$obj_lib = __NAMESPACE__.'\\'.$componentCode;
return new $obj_lib(&$this);
}
else return NULL;
}
I am getting a error saying that Call-time pass-by-reference has been removed in the line 6 of above function i.e., return new $obj_lib(&$this);
$obj_lib does not have a pass by reference parameter, so you cannot pass it a reference. Remove the & from &$this, or add & to the parameter wherever $obj_lib is defined
Related
This question already has answers here:
PHP 7.2 Function create_function() is deprecated
(6 answers)
Closed 1 year ago.
I have a function which im not entirely sure how to convert it to get working in newest php
$eventSponsor = array_map(create_function('$o', 'return $o["id"];'), $event->sponsors);
which method should i use in newest php version ?
yeah i was searching and i found this method called anonymous function so the code be like
$awe function ($o) {
return $o["id"];
};
$eventSponsor = array_map($awe,$event->sponsors); ```
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 6 years ago.
getting this php fatal error on this line when try apply theme
case('homeimage_texts'):
if(!empty(Params::getParam('homeimage'))){
foreach(Params::getParam('homeimage',false,false,false) as $key => $value){
osc_set_preference($key,trim($value),'osclasswizards_theme');
}
}
osc_add_flash_ok_message(__('Banner settings updated correctly', OSCLASSWIZARDS_THEME_FOLDER), 'admin');
osc_redirect_to(osc_admin_render_theme_url('oc-content/themes/'.OSCLASSWIZARDS_THEME_FOLDER.'/admin/settings.php#banner'));
break;
It looks like a PHP version issue. I you are using PHP 5.3 or below you may get this error message.
This question already has answers here:
Only variables should be passed by reference
(12 answers)
Closed 7 years ago.
Having this:
...
private $responseBuffer = array();
...
and within this line:
$lm = end(array_values($this->responseBuffer));
I get
Error: Only variables should be passed by reference (2048)
as both end and array_values are built in and do not have a call-by-referenceI'm puzzled, any one an idea?
(purpose: get the latest value out of $responseBuffer)
end function receives the arguement by reference, do like this:
$var = array_values($this->responseBuffer);
$lm = end($var);
This question already has answers here:
PHP 5.4 Call-time pass-by-reference - Easy fix available?
(3 answers)
PHP warning: Call-time pass-by-reference has been deprecated
(2 answers)
Closed 9 years ago.
I have this error in my wordpress webpage:
wordpress Fatal error: Call-time pass-by-reference has been removed in /home/xxx/public_html/wp-content/themes/xxx/functions.php on line 202
Here is the relevant code:
200 class pont_Walker extends Walker_Nav_Menu{
201 function end_el(&$output, $category, $depth, $args){
202 $output=preg_replace("/([^>]{1})(<\/a>)/", "$1<span></span>$2", &$output);
203 $output.="</li>\n";
204 }
Remove & from &$output & give a try. :)
function end_el($output, $category, $depth, $args) {.... }
and in
$output=preg_replace("/([^>]{1})(<\/a>)/", "$1<span></span>$2", &$output);
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Call-time pass-by-reference has been deprecated;
My Kohana site, get this alert in libraries file.
Call-time pass-by-reference has been deprecated
Thats problem line:
call_user_func('Formo_'.$name.'::load', & $this);
How can i solve this?
Remove the & before $this.
PHP5 doesn't need that added - all objects are passed as object identifiers by default, no need to mimic this with passing by reference as it was required for PHP 4.
To pass a variable by reference in php5 you need to have & on your function declaration. NOT when you are calling the function.
function call_user_func($param1, &$param2) {
// $param2 will be a reference
// as mentioned by damianb though objects are by default references
// http://php.net/manual/en/language.oop5.references.php
}
when calling this just pass in your params as normal and param2 will be passed by reference.
http://php.net/manual/en/language.references.pass.php
The above link clearely explains the error.
Note: There is no reference sign on a function call - only on function
definitions. Function definitions alone are enough to correctly pass
the argument by reference. As of PHP 5.3.0, you will get a warning
saying that "call-time pass-by-reference" is deprecated when you use &
in foo(&$a);.