Home Backend Development PHP Tutorial thinkphp(3.2.1),写源代码出现的一点有关问题。关于绝对地址的

thinkphp(3.2.1),写源代码出现的一点有关问题。关于绝对地址的

Jun 13, 2016 am 11:52 AM
define defined nbsp path thinkphp

thinkphp(3.2.1),写源代码出现的一点问题。关于绝对地址的。
我按照官方写的源码,自己对照的敲了一遍。刚刚开始敲。就发现了一点问题。
首先我先写的是thinkphp.php就是这个公共入口文件。

<?php<br />// +----------------------------------------------------------------------<br />// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]<br />// +----------------------------------------------------------------------<br />// | Copyright (c) 2006-2013 http://thinkphp.cn All rights reserved.<br />// +----------------------------------------------------------------------<br />// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )<br />// +----------------------------------------------------------------------<br />// | Author: liu21st <[email&#160;protected]><br />// +----------------------------------------------------------------------<br /><br />//----------------------------------<br />// ThinkPHP公共入口文件<br />//----------------------------------<br /><br />// 记录开始运行时间<br />$GLOBALS['_beginTime'] = microtime(TRUE);<br />// 记录内存初始使用<br />define('MEMORY_LIMIT_ON',function_exists('memory_get_usage'));<br />if(MEMORY_LIMIT_ON) $GLOBALS['_startUseMems'] = memory_get_usage();<br /><br />// 版本信息<br />const THINK_VERSION     =   '3.2.1';<br /><br />// URL 模式定义<br />const URL_COMMON        =   0;  //普通模式<br />const URL_PATHINFO      =   1;  //PATHINFO模式<br />const URL_REWRITE       =   2;  //REWRITE模式<br />const URL_COMPAT        =   3;  // 兼容模式<br /><br />// 类文件后缀<br />const EXT               =   '.class.php'; <br /><br />// 系统常量定义<br />defined('THINK_PATH') 	or define('THINK_PATH',     __DIR__.'/');<br />echo THINK_PATH;<br />defined('APP_PATH') 	or define('APP_PATH',       dirname($_SERVER['SCRIPT_FILENAME']).'/');<br />defined('APP_STATUS')   or define('APP_STATUS',     ''); // 应用状态 加载对应的配置文件<br />defined('APP_DEBUG') 	or define('APP_DEBUG',      false); // 是否调试模式<br /><br />if(function_exists('saeAutoLoader')){// 自动识别SAE环境<br />    defined('APP_MODE')     or define('APP_MODE',      'sae');<br />    defined('STORAGE_TYPE') or define('STORAGE_TYPE',  'Sae');<br />}else{<br />    defined('APP_MODE')     or define('APP_MODE',       'common'); // 应用模式 默认为普通模式    <br />    defined('STORAGE_TYPE') or define('STORAGE_TYPE',   'File'); // 存储类型 默认为File    <br />}<br /><br />defined('RUNTIME_PATH') or define('RUNTIME_PATH',   APP_PATH.'Runtime/');   // 系统运行时目录<br />defined('LIB_PATH')     or define('LIB_PATH',       realpath(THINK_PATH.'Library').'/'); // 系统核心类库目录
Copy after login

就是到了这一行。定义常量LIB_PATH。就出了问题了。我首先输出THINK_PATH(第35行定义),输出“D:\wamp\www\bbbb\ThinkPHP/”但是当常量后面加上Library,然后realpath函数进行解析的时候,就不能正常解析了,只能显示最后面的那个"/"。
然后我找到thinkphp的框架,不动源码,然后公共入口文件里面echo了一下,没有问题。
但是,当我直接把这个公共入口文件全部复制到一个新的文件的时候,出现了跟我一样的错误。请问这是为什么?
可能有说的有些乱,希望不要介意。
------解决方案--------------------
没有足够的把握,不要修改框架的核心代码
使用框架时,不要改动允许你修改的文件外任何文件

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

How to turn off private browsing authentication for iPhone in Safari? How to turn off private browsing authentication for iPhone in Safari? Nov 29, 2023 pm 11:21 PM

In iOS 17, Apple introduced several new privacy and security features to its mobile operating system, one of which is the ability to require two-step authentication for private browsing tabs in Safari. Here's how it works and how to turn it off. On an iPhone or iPad running iOS 17 or iPadOS 17, Apple's browser now requires Face ID/Touch ID authentication or a passcode if you have any Private Browsing tab open in Safari and then exit the session or app to access them again. In other words, if someone gets their hands on your iPhone or iPad while it's unlocked, they still won't be able to view your privacy without knowing your passcode

Win10/11 digital activation script MAS version 2.2 re-supports digital activation Win10/11 digital activation script MAS version 2.2 re-supports digital activation Oct 16, 2023 am 08:13 AM

The famous activation script MAS2.2 version supports digital activation again. The method originated from @asdcorp and the team. The MAS author calls it HWID2. Download gatherosstate.exe (not original, modified) from https://github.com/massgravel/Microsoft-Activation-Scripts, run it with parameters, and generate GenuineTicket.xml. First take a look at the original method: gatherosstate.exePfn=xxxxxxx;DownlevelGenuineState=1 and then compare with the latest method: gatheros

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to set the PATH environment variable of the Linux system Steps to set the PATH environment variable of the Linux system Feb 18, 2024 pm 05:40 PM

How to set the PATH environment variable in Linux systems In Linux systems, the PATH environment variable is used to specify the path where the system searches for executable files on the command line. Correctly setting the PATH environment variable allows us to execute system commands and custom commands at any location. This article will introduce how to set the PATH environment variable in a Linux system and provide detailed code examples. View the current PATH environment variable. Execute the following command in the terminal to view the current PATH environment variable: echo$P

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

See all articles