S
S
Shaheen2022-03-29 16:05:46
PHP
Shaheen, 2022-03-29 16:05:46

What is the best way to write code?

What is the best way to write code?

$app_path = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}";

$app_path = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

$app_path = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s" : "") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2022-03-29
@delphinpro

$app_path =
  '//'           // просто двойной слэш будет использовать текущую схему
 .'mysite.com/'  // домен сайта вы знаете и он не меняется. или в константу его. или в конфиг
 .$_SERVER['REQUEST_URI'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question