I'm using the code below to choose an image based on the domain.
the only difference between environments is wamp is running PHP 7 and my host 7.1 and I've been unable to get a copy of wamp with PHP 7.1 included.
on the live site, the end result is a blank white page with the PHP error on the 'else' line
I'm not sure if this is correct but after $logo_img = "3_logo.svg"
if I add the semicolon you get a white page but without works just fine.
<?php
$host = $_SERVER['HTTP_HOST'];
$logo_img = '';
if($host == "1.co.uk") {
$logo_img = "1_logo.svg";
}
else if($host == "2.co.uk") {
$logo_img = "2_logo.svg";
}
else($host == "3.co.uk") {
$logo_img = "3_logo.svg" //with semicolon errors - unexpected ';'
}
?>
any help appreciated!!
UPDATE:
var_dump ($_SERVER['HTTP_HOST']);
returns
Localhost
string 'localhost' (length=9)
Live site
string(23) "www.domain.co.uk"
Please fix this here is syntax error
else($host == "3.co.uk") {
$logo_img = "3_logo.svg" //with semicolon errors - unexpected ';'
}
you need to write
elseif($host == "3.co.uk") {
$logo_img = "3_logo.svg";
}
else{ ..... }