PHP calls the physical path URL path root directory $_SERVER

 Root directory D:\phpstudy_pro\WWW\sphp\app\api\controller\index.php

 URL: https://sphp.com/index.php?m=index&a=root

<?php       
        $root = __FILE__; //D:\phpstudy_pro\WWW\sphp\app\api\controller\index.php
        $root = $_SERVER['PHP_SELF']; //正在执行脚本的文件名 /index.php
        $root = $_SERVER['HTTP_HOST']; //当前请求的 Host: 头部的内容 sphp.com
        $root = $_SERVER['REQUEST_SCHEME']; //网址协议 https
        $root = $_SERVER['DOCUMENT_ROOT']; //当前运行脚本所在的文档根目录 D:/phpstudy_pro/WWW/sphp
        $root = $_SERVER['SCRIPT_FILENAME'];//当前执行脚本的绝对路径名 D:/phpstudy_pro/WWW/sphp/index.php
        $root = $_SERVER['REQUEST_URI']; //URL /index.php?m=index&a=root
        $root = $_SERVER['REMOTE_ADDR'];//当前用户IP 127.0.0.1
        $root = $_SERVER['SERVER_PORT'];// 服务器所使用的端口 443
        $root = $_SERVER['HTTP_REFERER']; //链接到当前页面的前一页面的 URL 地址
        $root = $_SERVER['REMOTE_HOST']; //当前用户主机名
        $root = $_SERVER['SERVER_NAME']; //服务器主机的名称 sphp.com
        $root = $_SERVER['REMOTE_PORT']; //端口 51739
        $root = $_SERVER['HTTPS'];//如果通过https访问,则被设为一个非空的值(on),否则返回off on
        $root = $_SERVER['SERVER_PROTOCOL']; //请求页面时通信协议的名称和版本 HTTP/1.1
        $root = getcwd(); //D:\phpstudy_pro\WWW\sphp
        echo $root;


?>

 

Guess you like

Origin blog.csdn.net/weixin_58881595/article/details/118150958