sherry wrote: Since the code is the same for all
Uh.. no, it definitely is not. It's about as different as night and day.
sherry wrote:how come the output is different between the relative path and the URL version
It's not that you're using a relative path (vs. absolute), it's that you're comparing a local file path to a URL - the two concepts have no correlation between them at all.
You're essentially asking why viewing the output of a PHP script through a web browser is different than simply opening the PHP script directly.
sherry wrote:It's the same code that traverses line-by-line and ultimately gets executed regardless of its route I thought.
I don't know what you're referring to here, but hopefully by now I've illustrated why including a file locally is worlds apart from including that same file via an HTTP request.
sherry wrote:Also, how to know which version to use and when?
Er... do you want to get the rendered output of a PHP script as it would be sent to a web browser, or do you want to include a local file (e.g. a .php script) instead? If you can answer that question (which I sure hope you can), then it should be obvious which "version" to use.