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

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

  •  12-06-2023
  •  | 
  •  

Question

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?

Était-ce utile?

La solution

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.

Autres conseils

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);
 }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top