So, now I have a file. The file is at /home/johndoe/index.html
.
I host, using something like XAMPP, which hosts the folder /home
at localhost
.
So this is the list of variables I have:
$server_addr = "localhost";
$server_root = "/home";
$file_dir = "/home/johndoe/index.html";
Now, in PHP, I'm trying to get the link to access /home/johndoe/index.html
.
What I want to do:
function getLink($file_dir, $server_addr, $server_root) {
// Do something here
return "SOMETHING HERE";
}
echo getLink("/home/johndoe/index.html", "localhost", "/home");
// Expect 'localhost/johndoe/index.html' here.
I decided that only doing things on the thing is not a wise way.
Is there any native functions, or how can I write a function by 'using' the file instead of doing something on these three string's?