我是编程新手,因此决定尝试PHP。
我正在尝试设置variable $_SERVER["SERVER_NAME"]
。
不幸的是,我遇到一些错误。
该代码是从this Youtube tutorial复制而来的,因此应该是正确的。
$server = [
'Host Server Name' => $_SERVER['SERVER_NAME'],
'Host Header' => $_SERVER['HTTP_HOST'],
'Server Software' => $_SERVER['SERVER_SOFTWARE'],
'Document Root' => $_SERVER['DOCUMENT_ROOT'],
'Current Page' => $_SERVER['PHP_SELF'],
'Script Name' => $_SERVER['SCRIPT_NAME'],
'Absolute Path' => $_SERVER['SCRIPT_FILENAME']
];
//print_r($server);
// Create Client Array
$client = [
'Client System info' => $_SERVER['HTTP_USER_AGENT'],
'Client IP' => $_SERVER['REMOTE_ADDR'],
'Remote Port' => $_SERVER['REMOTE_PORT']
];
错误:
Notice: Undefined variable:** server in C:\xampp\htdocs\phpsandbox\website2\server-info.php on line 7
Fatal error: Uncaught Error: Unsupported operand types in C:\xampp\htdocs\phpsandbox\website2\server-info.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\phpsandbox\website2\server-info.php on line 7
感谢任何人的支持!