Relative vs Absolute Paths

I have been taught that you should almost always try and use relative paths (e.g. includes) because they grow with your app and its home.

Are there any times where absolute paths are better?

I am reading a book where the author made a good portion of his “includes” absolute paths, and when I put the code into NetBeans - where my project folder apparently is considered “root” in terms of paths - everything was broken! (Had he used relative paths, I could have just dumped his code into either my local pc’s development environment or in my web hosting account and there would be no difference AND things would have run the first time…)

TomTees

Absolute paths are better in those situations where relative paths wouldn’t work or would cause problems or are awkward to work out.

Some examples:

Referencing anything from a different domain - even if they are both folders inside the same hosting account

Where a file can have different relative addresses depending on how you reference it (eg a file that can be either a page by itself or an include within a page in a different folder).

Where the relative address involves swapping through so many folders that it gets difficult to keep track of exactly what the relative address is.

That HAS to be the quote of the year… :rofl: