So I had this trouble with a PHP code that I solved, but I don't really know how it works.
I tried to add this to every single file
<?php include '/nav.php'; ?>
So I can only have one file to edit the navbar instead of the whole php files.
The problem came up when I added that code to the files of another folder (ie. /general/vision.php) and I got an error (file not found). I though it was because I only hav the 'nav.php' file on the root of the site.
So, just for fun, I changed the sentence of the /general/vision.php file to
<?php include '../nav.php'; ?>
And it worked. I didn't changed the nav.php from the root, and it worked.
I'm glad it did, but I don't know why. How does that /../ works? Is that listed on the PHP documentation?
..
is OS nomenclature for "up a directory." It's nothing PHP specific.
Take a look at the concept of Relative paths.. might shed some light. Relative paths vs Absolute paths.
..
refers to the parent directory. This is pretty standard for all operating systems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With