不明白为什么我会收到未定义的索引错误


Can not understand why i am getting a Undefined index error

嗨,我收到错误 未定义的索引:在这一行HTTP_HOST,你们中的任何一个人都可以告诉我哪里出错了

define("SCH_WSLINK", "{$httpS}://{$_SERVER['HTTP_HOST']}");

干杯

$httpS定义吗?

$httpS = 'https';
define("SCH_WSLINK", "{$httpS}://{$_SERVER['HTTP_HOST']}");

上面的代码对我有用...

var_dump(SCH_WSLINK);
string(16) "https://test.loc"
错误的

原因是$httpS被解释为未定义的变量,这将起作用:

<?php
    define("SCH_WSLINK", "{'$httpS}://{$_SERVER['HTTP_HOST']}");
    echo SCH_WSLINK;
?>