Do you have a web server and a development server rendering different versions of the $_SERVER['DOCUMENT_ROOT'] superglobal?

Mmm, me too. I’d have pulled my hair out if I had any. Made me feel rather defeated after thinking I’d fixed things so that one DB connect call would work on two+ servers. Fancy that – PHP behaving unpredictably – anybody would think I was playingworking very hard with CSS.

I had finally got round to using substr to trim the public_htmlpart off a DocumentRoot path to get me an absolutely relative link to a safe place…
ie  (substr($_SERVER['DOCUMENT_ROOT'], 0, -12). )
ie keeping the DB connect information out of the public view

Anyway for how to fix the trailing slash problem you should point your google at the New Zealand PHP advocates or crib directly from here:


We heart Nathan Kennedy

Last updated on 5th September 2018