Table of Contents
thinkphp里面的路径问题
Home php教程 php手册 thinkphp里面的路径问题

thinkphp里面的路径问题

Jun 13, 2016 am 08:50 AM
path question

thinkphp里面的路径问题

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

 

public function test()

{

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

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

    echo '__ROOT__ ' . __ROOT__ . '
';

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

    echo 'thinkphp里面的路径问题';

    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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to fix error: Main class not found or loaded in Java How to fix error: Main class not found or loaded in Java Oct 26, 2023 pm 11:17 PM

This video cannot be played due to a technical error. (Error Code: 102006) This guide provides simple fixes for this common problem and continue your coding journey. We will also discuss the causes of Java errors and how to prevent it in the future. What is "Error: Main class not found or loaded" in Java? Java is a powerful programming language that enables developers to create a wide range of applications. However, its versatility and efficiency come with a host of common mistakes that can occur during development. One of the interrupts is Error: Main class user_jvm_args.txt not found or loaded, which occurs when the Java Virtual Machine (JVM) cannot find the main class to execute a program. This error acts as a roadblock even in

Different uses of slashes and backslashes in file paths Different uses of slashes and backslashes in file paths Feb 26, 2024 pm 04:36 PM

A file path is a string used by the operating system to identify and locate a file or folder. In file paths, there are two common symbols separating paths, namely forward slash (/) and backslash (). These two symbols have different uses and meanings in different operating systems. The forward slash (/) is a commonly used path separator in Unix and Linux systems. On these systems, file paths start from the root directory (/) and are separated by forward slashes between each directory. For example, the path /home/user/Docume

What is the difference in the 'My Computer' path in Win11? Quick way to find it! What is the difference in the 'My Computer' path in Win11? Quick way to find it! Mar 29, 2024 pm 12:33 PM

What is the difference in the "My Computer" path in Win11? Quick way to find it! As the Windows system is constantly updated, the latest Windows 11 system also brings some new changes and functions. One of the common problems is that users cannot find the path to "My Computer" in Win11 system. This was usually a simple operation in previous Windows systems. This article will introduce how the paths of "My Computer" are different in Win11 system, and how to quickly find them. In Windows1

How to solve the problem that jQuery cannot obtain the form element value How to solve the problem that jQuery cannot obtain the form element value Feb 19, 2024 pm 02:01 PM

To solve the problem that jQuery.val() cannot be used, specific code examples are required. For front-end developers, using jQuery is one of the common operations. Among them, using the .val() method to get or set the value of a form element is a very common operation. However, in some specific cases, the problem of not being able to use the .val() method may arise. This article will introduce some common situations and solutions, and provide specific code examples. Problem Description When using jQuery to develop front-end pages, sometimes you will encounter

Teach you how to diagnose common iPhone problems Teach you how to diagnose common iPhone problems Dec 03, 2023 am 08:15 AM

Known for its powerful performance and versatile features, the iPhone is not immune to the occasional hiccup or technical difficulty, a common trait among complex electronic devices. Experiencing iPhone problems can be frustrating, but usually no alarm is needed. In this comprehensive guide, we aim to demystify some of the most commonly encountered challenges associated with iPhone usage. Our step-by-step approach is designed to help you resolve these common issues, providing practical solutions and troubleshooting tips to get your equipment back in peak working order. Whether you're facing a glitch or a more complex problem, this article can help you resolve them effectively. General Troubleshooting Tips Before delving into specific troubleshooting steps, here are some helpful

Clustering effect evaluation problem in clustering algorithm Clustering effect evaluation problem in clustering algorithm Oct 10, 2023 pm 01:12 PM

The clustering effect evaluation problem in the clustering algorithm requires specific code examples. Clustering is an unsupervised learning method that groups similar samples into one category by clustering data. In clustering algorithms, how to evaluate the effect of clustering is an important issue. This article will introduce several commonly used clustering effect evaluation indicators and give corresponding code examples. 1. Clustering effect evaluation index Silhouette Coefficient Silhouette coefficient evaluates the clustering effect by calculating the closeness of the sample and the degree of separation from other clusters.

The problem of generalization ability of machine learning models The problem of generalization ability of machine learning models Oct 08, 2023 am 10:46 AM

The generalization ability of machine learning models requires specific code examples. With the development and application of machine learning becoming more and more widespread, people are paying more and more attention to the generalization ability of machine learning models. Generalization ability refers to the prediction ability of a machine learning model on unlabeled data, and can also be understood as the adaptability of the model in the real world. A good machine learning model should have high generalization ability and be able to make accurate predictions on new data. However, in practical applications, we often encounter models that perform well on the training set, but fail on the test set or real

How to find the storage path of RPM files in Linux system? How to find the storage path of RPM files in Linux system? Mar 14, 2024 pm 04:42 PM

In Linux systems, RPM (RedHatPackageManager) is a common software package management tool used to install, upgrade and delete software packages. Sometimes we need to find the storage path of an installed RPM file for search or other operations. The following will introduce how to find the storage path of the RPM file in the Linux system, and provide specific code examples. First, we can use the rpm command to find the installed RPM package and its storage path. Open

See all articles