TL;DR: What alternatives to the last code sample on this page are there when trying to use relative links on pages included with PHP\'s include com
include
relative URL, or where your script located relative to document root
preg_replace('/[\\\\\\/]+/', '/', '/' . substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])) . '/' )