1

What does the period (.) in the following php function mean:

require("./folder/file.php");

And on the security issue, is using the function in the above way safe?

  • Does this answer your question? [What does a dot mean in a URL path?](https://stackoverflow.com/questions/6008829/what-does-a-dot-mean-in-a-url-path) – kmoser Sep 13 '22 at 05:12
  • @kmoser Although it's the same exact meaning, it's probably not the best example since `require` only accepts URLs when some magic is involved (and it's a dubious practice from security standpoint). – Álvaro González Sep 13 '22 at 07:49
  • I couldn't find a proper question to link, but here's an overview: https://phpdelusions.net/articles/paths – Álvaro González Sep 13 '22 at 07:50
  • 2
    @ÁlvaroGonzález Here is a better example: https://superuser.com/questions/37449/what-are-and-in-a-directory – kmoser Sep 13 '22 at 22:33

1 Answers1

4

. (dot) means a relative path, require("./folder/file.php"); means that you are working in the same folder. There no risk at all, it is just a reference to a file.

.. (two dots) is one level higher ../../ (two dots slashes) two levels higher

further info

user101289
  • 9,888
  • 15
  • 81
  • 148
jmvcollaborator
  • 2,141
  • 1
  • 6
  • 17