Home > Software design >  Why php scripts must be saved in www folder?
Why php scripts must be saved in www folder?

Time:03-25

I just started learning PHP and I'm confusing about 2 questions.

  1. Why php scripts must be saved within a folder called "www". enter image description here

  2. 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.

enter image description here

In index.php, I have a navigation bar that looks like: enter image description here

<li >
    <a  href="/categories/category4_4/category4_4.php" target="_blank">Contact</a>
</li>

The error I got when I clicked on the link:

enter image description here

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
  • Related