$_SERVER[“SCRIPT_URI”] not working? alternative?

前端 未结 11 2506
北恋
北恋 2020-12-17 17:17

This is odd, but for some reason the $_SERVER[\"SCRIPT_URI\"] will not return the domain name when I am in child/sub-pages but will only work on the main page.

11条回答
  •  隐瞒了意图╮
    2020-12-17 17:38

    Depending on what you want, I'd use one of the following:

    1. $_SERVER['PHP_SELF'] for the script file location
    2. $_SERVER['SERVER_NAME'] for the host name

    From the php docs

    EDIT: Maybe PHP_SELF isn't the best. See comments.

提交回复
热议问题