Dir manipulation (__ DIR__) does not work

The following behavior is different from the host :

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

localhost: (works fine):

 DIR:C:\Program Files\VertrigoServ\www 

why is this other conclusion?

+7
source share
3 answers

You need PHP 5.3 to use __DIR__

Manual page

In previous versions, instead of dirname(__FILE__) you can use

+31
source

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

+2
source

Try:

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

Folder: localhost or root :)

0
source

All Articles