Path in thinkphp _ PHP Tutorial

Source: Internet
Author: User
Path Problems in thinkphp. The path problem in thinkphp is written in the following statement publicfunctiontest () {echodirname (_ FILE _) in the method of a controller __). dirname (_ FILE __). br; path problem in echodirname () thinkphp
Write the following statement in the method in a controller.

Public function test ()

{

Echo 'dirname (_ FILE _) '. dirname (_ FILE __).'
';

Echo 'dirname () '. dirname ().'
';

Echo ''..'
';

// Echo '_ Public _'. _ Public __.'
';

Echo '';

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 __;

}

The result of browser access to this method is:

Dirname (_ FILE _) D: \ WWW \ tpapp \ Application \ Home \ Controller

Dirname ()\

/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

Compile the following statement in the method of a controller: public function test () {echo dirname (_ FILE __). dirname (_ FILE __). br/; echo dirname ()...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.