php - How to fix this "undefined index" if statement -


my code below

$base = if((!empty(($_server['https']  ? 'https' : 'http') . '://' . $_server['http_host'] . '/')); 

i'm checking whether $_server['https'] not empty notice:

notice: undefined index: https in d:\xampp\htdocs\flower-shop\flowers.php on line 24

the following code should work. if notice, in php shorthand don't include if word.

<?php    $base = (isset($_server['https']) ? 'https' : 'http').'://'.$_server['http_host'].'/'; ?> 

i not rely on $_server['http_host'] since can modified client , can cause huge issues.


Comments

Popular posts from this blog

angularjs - Showing an empty as first option in select tag -

qt - Change color of QGraphicsView rubber band -

c++ - Visible files in the "Projects" View of the Qt Creator IDE if using the CMake build system -