- Edited
how links work in php from project folder to nested folders ?
how links work in php from project folder to nested folders ?
nb6
What are you asking?
Relative paths??
Hard to say without more specifics on what you are really looking for.
Possibly what you're interested in is the super-global variable $_SERVER['DOCUMENT_ROOT']?
that link dsnt work.
<?php
$dr = $_SERVER["DOCUMENT_ROOT"].'/index.php';
echo <<<html
<a href="$dr">home</a>
html;
?>
Oh, so it's nothing to do with folders. It's about URLs.
echo "<a href='/index.php'>home</a>";
Of course, the web server (e.g. Apache or other options) has to be configured to know where the home directory is on the server's file system, but that's separate from PHP.
nb6 This ..
<?php
$dr = $_SERVER["DOCUMENT_ROOT"].'/index.php';
echo "<a href=\"<?=$dr ?>\">home</a>";
?>
NogDog
Yes. Should be ....
$dr = $_SERVER["DOCUMENT_ROOT"].'/index.php';
echo "<a href=\"".$dr."\">home</a>";
which renders as a link "home" that links to the absolute path
<a href="C:\inetpub\wwwroot/index.php">home</a>
in my case.
Should have tested it.
nb6
This .......
$dr = $_SERVER["DOCUMENT_ROOT"].'/index.php';
echo "<a href=\"".$dr."\">home</a>";