I just started learning PHP and I'm confusing about 2 questions.
I have a php projects where there are few sub-pages that I want to link from the index.php. For example, I want navigate to the category4_4.php from index.php via an anchor tag.
In index.php, I have a navigation bar that looks like:
<li >
<a href="/categories/category4_4/category4_4.php" target="_blank">Contact</a>
</li>
The error I got when I clicked on the link:
Did I wrongly declare my file path? From what I know, starting with a backslash "/" always refers to the root folder which is the 'frontend-cms-template' in this case.
CodePudding user response:
Did I wrongly declare my file path? From what I know, starting with a backslash "/" always refers to the root folder which is the 'frontend-cms-template' in this case.
No, to PHP "root" is DOCUMENT_ROOT
, which is usually https://localhost
in the browser. To see which folder document root is in relation to your file system, display the predefined variable $_SERVER
like so:
echo($_SERVER['DOCUMENT_ROOT']);
In your case it's probably C:\wamp64\www
.
CodePudding user response:
you can use ./ for one back directory and 2nd back use ../
Contact