0

I am implementing phpmobilizer on a website. I have created a subdomain "m" which contains a file with the following code (this is just one section):

function __construct($url){
    $this->url = $url;
    $this->server = preg_replace('/^m\./', '', $_SERVER['SERVER_NAME']);
    $this->ext = strtolower(end(explode('.', $this->url)));
    $this->patterns = array();
    $this->replacements = array();
    $this->cookieDomain = $this->__getCookieDomain();
}

The error I am getting is on line 15:

$this->ext = strtolower(end(explode('.', $this->url)));

Strict Standards: Only variables should be passed by reference in website.com/m/phpmobilizer.class.php on line 15

This is the code I am using in the head section to redirect mobile users to the "m" subdomain. I have tested the mobile subdomain with Google's mobile friendly test and it is working correctly.

bmargulies
  • 97,814
  • 39
  • 186
  • 310
user3321565
  • 59
  • 1
  • 5

1 Answers1

0

The error is being caused by the use of 'end()'. The array is passed to end() by reference.

Try splitting the code up e.g.

$urlParts = explode('.', $this->url);
$this->ext = strtolower(end($urlParts));

Reference: http://php.net/manual/en/function.end.php

Sharn White
  • 624
  • 3
  • 15