I have a root path which can be defined in a file that inside this path:
define('FILE_ROOT', dirname( __FILE__ ) )
This can get an output of D:\xampp\htdocs\library\includes\templates
inside this templates directory, there’s a folder and its relative path is defined in another software:
$file_short_path = 'USERS_DATA/';
Now, I want to get the full path. I tried:
$file_full_path = FILE_ROOT . $file_short_path
the result is D:\xampp\htdocs\library\includes\templatesUSERS_DATA/
if I add ‘/’ after the FILE_ROOT, it becomes a wrong path:
$file_full_path = FILE_ROOT . '/' . $file_short_path
D:\xampp\htdocs\library\includes\templates/USERS_DATA/
if I add ‘\’ , I got syntax error:
$file_full_path = FILE_ROOT . '\' . $file_short_path
How can I get the correct file_full_path?
You needs to escape the
\. You can add the\twice.