Reputation: 6707
Here is my code:
<?php
echo __DIR__."/../css/styles-home.css";
?>
It prints:
C:\xampp\htdocs\myweb\ltk\application/../css/styles-home.css
While this is the expected result:
C:\xampp\htdocs\myweb\ltk/css/styles-home.css
How can I get that ^ ?
Upvotes: 0
Views: 73
Reputation: 362
Because you are just echo-ing the file path, the "../" isn't going to take you one step up in your directories, it's just going to print the "../". To go up one step, use the following code inline with your echo statement:
For PHP 5.3+ use:
echo realpath(__DIR__ . '/..')."/css/styles-home.css";
Or in PHP < 5.3 use:
echo realpath(dirname(__FILE__) . '/..')."/css/styles-home.css";
Upvotes: 1