Home > php教程 > php手册 > thinkphp里面的路径问题_PHP教程_编程技术

thinkphp里面的路径问题_PHP教程_编程技术

WBOY
Release: 2016-06-20 12:33:04
Original
823 people have browsed it

在一个控制器里的方法里写下面的语句

 

public function test()

{

    echo 'dirname(__FILE__) ' . dirname(__FILE__) . '
';

    echo 'dirname(__ROOT__) ' . dirname(__ROOT__) . '
';

    echo '__ROOT__ ' . __ROOT__ . '
';

    //echo '__Public__ ' . __Public__ . '
';

    echo 'thinkphp里面的路径问题_PHP教程_编程技术';

    echo '__FILE__ ' . __FILE__ . '
';

    echo '$_SERVER["PHP_SELF"]' . $_SERVER['PHP_SELF'] . '
';

    echo '$_SERVER["SCRIPT_NAME"]' . $_SERVER['SCRIPT_NAME'] . '
';

    echo '$_SERVER["SERVER_HOST"]' . $_SERVER['SERVER_HOST'] . '
';

    echo '$_SERVER["SERVER_NAME"]' . $_SERVER['SERVER_NAME'] . '
';

    echo '$_SERVER["SERVER_PROTOCOL"]' . $_SERVER['SERVER_PROTOCOL'] . '
';

    echo '$_SERVER["SERVER_FILENAME"]' . $_SERVER['SCRIPT_FILENAME'] . '
';

    echo dirname($_SERVER['SCRIPT_FILENAME']);

    echo __DIR__;

}

浏览器访问这个方法的结果是

dirname(__FILE__) D:\WWW\tpapp\Application\Home\Controller

dirname(__ROOT__) \

__ROOT__ /tpapp

banner1.jpg__FILE__ D:\WWW\tpapp\Application\Home\Controller\ApiController.class.php

$_SERVER["PHP_SELF"]/tpapp/index.php/home/api/test

$_SERVER["SCRIPT_NAME"]/tpapp/index.php

$_SERVER["SERVER_HOST"]

$_SERVER["SERVER_NAME"]localhost

$_SERVER["SERVER_PROTOCOL"]HTTP/1.1

$_SERVER["SERVER_FILENAME"]D:/WWW/tpapp/index.php



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template