Strict Standards: Only variables should be passed by reference (qdig gallery)

StackOverflow https://stackoverflow.com/questions/22298172

  •  12-06-2023
  •  | 
  •  

문제

The code from Qdig Gallery is:

$excl_imgs[] = end($logo_arrray = explode('/', $header['css_logo_url']));
$excl_imgs[] = end($bg_img_array = explode('/', $header['css_bg_img_url']));

which gives the above error (Strict Standards).

How do I fix this?

도움이 되었습니까?

해결책

Do this instead and your error should go away:

$logo_arrray = explode('/', $header['css_logo_url']);
$bg_img_array = explode('/', $header['css_bg_img_url']);

$excl_imgs[] = end($logo_arrray);
$excl_imgs[] = end($bg_img_array);

You should always try and fix any Strict Standards warning and not just hide them.

다른 팁

I liked to do this to have my code in one line, you can write this method and use end_legacy instead of end when want to use end like that.

 function end_legacy($arr){
   if (empty($arr))return false;
   if ( PHP_VERSION_ID > 50400) {
     $count = count($arr);
     $arr = array_values($arr);
     return $arr[ $count-1 ];
   }
   return end($arr);
 }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top