'Why php scripts must be saved in www folder?
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 class="nav-item">
<a class="nav-link" 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.
Solution 1:[1]
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.
Solution 2:[2]
you can use ./ for one back directory and 2nd back use ../
ContactSources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Mohammad Sajid Choudhary |



