开发者

dir manipulation(__DIR__) not working

开发者 https://www.devze.com 2023-04-05 06:36 出处:网络
the following behaves different in host: echo \'DIR:\' .__DIR__; // DIR:__DIR__ localhost:(works fine):开发者_如何学Python

the following behaves different in host:

echo 'DIR:' .__DIR__; // DIR:__DIR__

localhost:(works fine):

开发者_如何学Python
DIR:C:\Program Files\VertrigoServ\www

why this different output?


You need PHP 5.3 to use __DIR__

Manual page

On previous versions you may use dirname(__FILE__) instead


According to the PHP magic constants docs, the __DIR__ constant was added only in php 5.3.0. You're probably using an older version in your "host" environment.


Try:

<? echo realpath(dirname(__DIR__)); ?>

Folder: localhost or root :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号