0

I'm willing to ask a question is possible to get the path of the file where the code is running simply inserting the filename? Does such a function exist?

Example

$filename = "file.php";
$file_path = pathfinder_function($filename);
echo $file_path;

And I do get something similar to this

all/file/path/file.php

also somethig similar for URLs.

Markus Zeller
  • 8,516
  • 2
  • 29
  • 35
  • Is https://stackoverflow.com/questions/32537477/how-to-use-dir what you are after? – Nigel Ren Jul 18 '20 at 12:09
  • Are you asking about the file path (the actual location of the file on the server) or the url (what you see in the browsers address bar)? And what do you mean by _"simply inserting the filename"_? Please give us some real example of what you're trying to do and the expected result and we might understand it better. – M. Eriksson Jul 18 '20 at 12:26
  • So you want to search for a file in the file system? There's no native PHP function for doing that. You will need to do some research and attempt to implement it yourself. If you get stuck on something specific along the way, come back, show us what you've tried and we can help you from there. – M. Eriksson Jul 18 '20 at 12:51

0 Answers0