what is the best way to convert a relative path to an absolute path?
<p>I am making a search script and want to stop any deep level search for files and folders outside of the web document root.</p>

<p>In case the user passes in something like <code>../../../../../../</code> I want to capture it and convert it into the absolute path that it points to, then perform some sanitation checks.</p>

<p>So in the example if <code>../../../../../</code> is converted to <code>/</code> I want to replace <code>/</code> with <code>$_SERVER['DOCUMENT_ROOT']</code> or any other function in PHP to push the search and lock it in the web server root.</p>
