Forum Moderators: coopster

Message Too Old, No Replies

path for "include" statement

         

wheel

3:37 pm on Aug 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've had my developer write an ajax script for use on someone else's blog. In the php script he's used an include statement for a couple of calculator type functions.

include "calculator.php";

let's say we drop that script into their /blog directory. Someone visits the post, the script works fine, it can find calculator.php.
But what happens once that page gets archived? Now it's going to be accessed like /blog/archives/2010/blogpost. Will the include statement still work? I'm thinking not.

rocknbil

4:55 pm on Aug 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This will always find it, wherever it lives.

include($_SERVER['DOCUMENT_ROOT'] . '/path_to/calculator.php');

Best case for using full paths, same for URL's:

src="/images/somefile.jpg"

not

src="images/somefile.jpg"

wheel

6:55 pm on Aug 23, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Excellent! Thank you rocknbill :). I appreciate the assistance.