我想知道如何给出另一个文件夹的包含路径。
例如,我有一个名为 test 文件夹的项目。在测试文件夹中有一个文件夹是 Assets 文件夹和 index.php 文件。在 assets 文件夹中有两个文件夹,分别是 include 和 xyz 文件夹。在 include 文件夹中有两个文件,分别是 header.php 和 footer.php。在 header.php 文件中有三个链接 home,product 和 customer。在 xyz 文件夹中有 product.php 和 customer.php 文件。
在 index.php、product.php 和 customer.php 中,我想包含 header.php 和 footer.php。
但我不能正确的路径。
<?php include('../../header.php');?>
......
<?php include('../../footer.php');?>
请帮助我,我怎样才能给出正确的路径,如果我点击产品链接,那么 header.php 和 footer.php 将被加载。
最佳答案
试试这个:
<?php
include_once(dirname(__FILE__) . '/database.class.php');
?>
关于php - 如果我想包含另一个文件夹,如何获取链接路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15023579/