Search code examples
phppathrequire-once

Require_once functionality Working


So, I have a directory structure like this:

include/
scripts/
contact.css
contactform.php
ReadMe.txt
show-captcha.php
thank-you.php

In the show_captcha.php file the following is added to include PHP file from the /include subdirectory.

require_once("./include/fgcontactform.php");

Thise code works perfectly.

My question here is shouldn't it be like this:

require_once("include/fgcontactform.php");

Without the ./ prefix? What is the meaning of this path?


Solution

  • Both

    require_once("./include/fgcontactform.php");
    

    and

    require_once("include/fgcontactform.php"); 
    

    mostly do the same thing.

    The '.' indicates the current working directory.