0

How can I get rid of this errors.

Line 8 : define('CURRENT_PAGE', basename($_SERVER['REQUEST_URI']));
Line 15: define('READ_PATH', $_SERVER['HTTP_HOST'].'/read.php?id=');

errors:

Undefined index: REQUEST_URI in ......... on line 8
Undefined index: HTTP_HOST in ....... on line 15
Andrew
  • 3
  • 2
  • 1
    Does this answer your question? ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Tangentially Perpendicular Dec 26 '21 at 10:49
  • 1
    Welcome to SO! This site is really for specific questions, it is not a debgging tool. Please check for other similar questions (like the ones listed above) before asking – Martin CR Dec 27 '21 at 13:55

1 Answers1

0

if you use CLI then u can check them for their existence but in the browser, HTTP_HOST will be available any time.

 if (!empty($_SERVER['HTTP_HOST'])) {
    define('CURRENT_PAGE', basename($_SERVER['HTTP_HOST']));
 }

 if (!empty($_SERVER['REQUEST_URI'])) {
     define('CURRENT_PAGE', basename($_SERVER['REQUEST_URI']));
 }
behzad m salehi
  • 1,038
  • 9
  • 23