à file.php
:Comment obtenir le chemin absolu du fichier appelant dans une fonction appelée en PHP?
call()...
Comment obtenir le chemin absolu de l'intérieur file.php
call()
?
Faites attention à ce que call()
puisse être défini dans un autre fichier.
another.php
:
function call(){..}
file.php
:
include(path_to_another.php);
call();
Pour obtenir des chemins relatifs jusqu'à la racine, j'ai utilisé '$ _SERVER ['REQUEST_URI']'. Avec ma fonction 'root()', je peux facilement obtenir le chemin '' ../../ '' vers la racine. @ user187291 et votre réponse m'a lancé; Merci! – AVProgrammer