Path of current PHP script relative to document root

前端 未结 4 2012
一整个雨季
一整个雨季 2021-02-14 09:08

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

4条回答
  •  甜味超标
    2021-02-14 09:28

    relative URL, or where your script located relative to document root

    preg_replace('/[\\\\\\/]+/', '/', '/' . substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])) . '/' )
    

提交回复
热议问题