gpt4 book ai didi

php - 如何格式化 PHP include() 绝对(而不是相对)路径?

转载 作者:IT王子 更新时间:2023-10-28 23:49:18 30 4
gpt4 key购买 nike

在我的 PHP 网站的各个页面和各种嵌套目录中,我想在相对于根目录的路径中包含一个特定文件。

我可以在这两个页面上放置什么命令...

http://www.example.com/pageone.php
http://www.example.com/somedirectory/pagetwo.php

...to include this page:

http://www.example.com/includes/analytics.php

This does not work:

<?php include('/includes/analytics.php'); ?>

托管在 Windows 上的 IIS 中重要吗?

最佳答案

您可以只使用 include $_SERVER['DOCUMENT_ROOT'] 。 "/includes/analytics.php";

关于php - 如何格式化 PHP include() 绝对(而不是相对)路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/344823/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com