简体   繁体   中英

real path in windows azure website using PHP

I try to get real path in PHP

this is my code

<?php
    echo "\n1.". realpath('../testerror/warning.php');
    echo "\n2.". realpath('warning/warning.php');
    echo "\n3.". realpath('/testerror/warning.php'); 
?>

I get the result

1.D:\home\site\wwwroot\testerror\warning.php
2.D:\home\site\wwwroot\testerror\warning\warning.php
3.        ----> (I got nothing)

why i get nothing from code number 3

This is a problem because I need to include_once /testerror/warning.php from various location that's not necessarily the main directory.

do not use realpath , it is buggy. Try to use __DIR__ and DIRECTORY_SEPARATOR

Try this

echo "\n3.". realpath('./testerror/warning.php'); 

this is a path in Unix so it doesn't return any thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM