Change relative link paths for included content in PHP

前端 未结 3 1912
日久生厌
日久生厌 2021-01-23 10:11

I have a PHP file at my server root.. index.php .. which include\'s .. DIR/main.php

Now .. DIR/main.php .. has relati

3条回答
  •  隐瞒了意图╮
    2021-01-23 10:30

    Assuming main.php is a mix of HTML and PHP then when you output a link you'll need to include a prefix:

    relative link
    

    Where $web_root is your root path ('DIR'). Probably a good idea to define it in a separate include file so you only have to define it once for all your scripts.

提交回复
热议问题