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

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

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

php - Cloud9 cloud IDE and CakePHP -