Is there a magic constant in PHP like __DIR__ but with unresolved symlinks?

58 Views Asked by At

Everything is in the title.

I am trying to write an app in php with client and server features. For testing purpose (at least), I need several clients. To not have to copy the written code, I thought using symbolic links. Something like this : My main "repository" is MyClient/scripts I create near MyClient a MyClient2 folder in which I create a symbolic link to be able to use all the scripts of MyClient for MyClient2

ln -s ../MyClient/scripts scripts

At the really beginning of my scripts I am allowed to create some const using __DIR__. I found a lot of workaround to get the value I am looking for from variables (for example : $_SERVER['PWD']) but this doesn't allow me to define a const.

So I am looking for a constant just like __DIR__ but with unresolved symlinks.

This gives the result with resolved symlink (not what I want)

<?php 
const mydir = __DIR__ ;
echo mydir;
?>

This throws a Fatal error (not what I want)

<?php 
const mydir = $_SERVER['PWD'] ;
echo mydir;
?>

EDIT This is not a duplicate of this question. My question doesn't involve define at all, while the linked one is explicitly asking for how it works. For my question define has been suggested as a workaround which good enough regarding my need.

0

There are 0 best solutions below