【问题标题】:how to add absolute path with php include如何使用 php include 添加绝对路径
【发布时间】:2012-09-30 15:08:25
【问题描述】:

我正在添加一个包含 php 的绝对路径。

$path="/";

instead of include('../connect.php');

i want to include like include($path.'connect.php');

【问题讨论】:

标签: php include-path


【解决方案1】:

我正在使用类似的东西。我正在使用链接中的 p 值来获取我的页面。 我在这里也拔出了你指的sn-p

$pages_dir = 'inc/content';
include($pages_dir.'/'.$p.'.inc.php');

【讨论】:

    【解决方案2】:

    如果你正在使用任何框架,那么就按照那个,否则你可以做以下:

    $path = __DIR__;
    include($path . '/connect.php'); // change this to match path
    

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 2010-12-17
      • 1970-01-01
      • 1970-01-01
      • 2012-09-15
      • 2013-11-30
      相关资源
      最近更新 更多