Jack
Jack

Reputation: 16724

dir manipulation(__DIR__) not working

the following behaves different in host:

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

localhost:(works fine):

DIR:C:\Program Files\VertrigoServ\www

why this different output?

Upvotes: 7

Views: 14115

Answers (3)

KingRider
KingRider

Reputation: 2257

Try:

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

Folder: localhost or root :)

Upvotes: 1

Asaph
Asaph

Reputation: 162831

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.

Upvotes: 2

RiaD
RiaD

Reputation: 47640

You need PHP 5.3 to use __DIR__

Manual page

On previous versions you may use dirname(__FILE__) instead

Upvotes: 31

Related Questions