Reputation: 174
Here is how I define my root folder:
<?php
define('BASEDIR', dirname(__DIR__).'/');
?>
It should be no problem in Linux, or at least that what I think. However, I develop my website on Windows with Wamp, so a slash (/) has been turned into backslash (\). And that's my problem, check my test code:
<?php
echo BASEDIR.'user.json'
//result: C:\wamp\www\website/user.json
?>
What should I do? I can't not just replace all the slash for Linux to backslash for Window. Because in the end, I will upload it to a Linux host.
Upvotes: 0
Views: 30
Reputation: 1107
Use DIRECTORY_SEPARATOR
constant to avoid these situations. Example below:
require_once DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR . 'Boostrap.php'
Upvotes: 1