PHP不能识别“./”和“/”相对路径,这是哪里配置不对?
PHP版本是5.3.29,这个程序之前在别的服务器上是正常的,现在移到新的服务器上,凡事有相对路径“./”和“../”的,都不能识别,提示类似下面的:
Warning: include_once(../../../../../Lang/zh-cn/calendar.php): failed to open stream: No such file or directory in D:\wwwroot\xingxing\web\admin\Tpl\default\Common\js\calendar\calendar.php on line 9
Warning: include_once(): Failed opening '../../../../../Lang/zh-cn/calendar.php' for inclusion (include_path='.;C:\php\pear') in D:\wwwroot\xingxing\web\admin\Tpl\default\Common\js\calendar\calendar.php on line 9
Notice: Undefined variable: _LANG in D:\wwwroot\xingxing\web\admin\Tpl\default\Common\js\calendar\calendar.php on line 11
Warning: Invalid argument supplied for foreach() in D:\wwwroot\xingxing\web\admin\Tpl\default\Common\js\calendar\calendar.php on line 11
文件路径是没有问题的,因为在别的服务器上都是正常的。如果把“./”改成dirname(__FILE__),程序也是可以正常运行的。但就是不能识别相对路径。请问这种情况是PHP哪里配置不对的吗,还是IIS配置不对。
因为程序是别人做的,而且很多地方都使用了相对路径,所以很难一个个文件去把路径都改成绝对路径。
下面网盘链接是phpinfo()的代码:
https://pan.baidu.com/s/1qWZHaKs
回复讨论(解决方案)
<?phpecho getcwd();echo dirname(__FILE__);?>
上面的代码输出的是:
C:\php
D:\wwwroot\xingxing\web
补充说明:在网站根目录下输出echo getcwd();显示出来的是:C:\php,而echo dirname(__FILE__);打印出来的是:D:\wwwroot\xingxing\web,而D:\wwwroot\xingxing\web
猜你就是用的 IIS
你需要在管理器的网站属性选项卡中 勾选 启用父路径
猜你就是用的 IIS
你需要在管理器的网站属性选项卡中 勾选 启用父路径
谢谢版主,以前IIS6的时候我记得有这个设置的,但是现在用的是IIS7,没找到这个选项,网上找到的也都是ASP设置父路径的方法
我是用的IIS7,win2008的,对服务器配置不懂,具体在哪里设置呢
http://www.softbar.com/blog/post/187.html
自己找找看吧,我几年前弄过。现在也记不清了
http://www.softbar.com/blog/post/187.html
自己找找看吧,我几年前弄过。现在也记不清了
这个是ASP的设置呢,PHP的没见有,还是IIS7就没有这玩意了
我猜你是权限不足的原因 比如 你PHP 网站绑定的是wwww/csdn 你来宾权限只到csdn 到不了wwww从而导致的
你试试给wwww 权限放大
你做了就知道!
问题解决了,你们两位说的问题都不是。我在网上下载一个同版本的PHP,然后把里面的php.ini替换了服务器上的php.ini就可以了。也不知道是php.ini里面哪里设置不对的。这个是阿里云的主机,PHP不知道是原来自带的还是后面装上的,反正因为这个设置就有各种各样的问题,连getcwd();都获取不到当前目录,获取到的是c:\php目录

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
