【发布时间】:2015-06-22 18:22:27
【问题描述】:
我正在尝试使用包含创建一个简单的 php 页面,但我发现很难使用 ../ 导航 url 以找到文件夹的正确路径。
有没有一种简单的方法来构建一个简单的 php 导航。只在本地做,不使用mysql等。
<a class="list-group-item" href="index.php">Overview <i class="fa fa-tachometer fa-fw"></i></a>
<a class="list-group-item" href="ticket/tickets.php">Tickets <i class="fa fa-ticket fa-fw"></i></a>
<? php
$indexURL = ('project/*');
?>
<div id="sidebar" class="sample">
<div class="search">
<input type="search" placeholder="Search..."> <i class="fa fa-search fa-2x"></i>
</div>
<div class="list-group">
<a class="list-group-item" href="<?php echo '$indexURL' ?>/index.php">Overview <i class="fa fa-tachometer fa-fw"></i></a>
【问题讨论】:
-
使用绝对url:
/ticket/tickets.php等或使用定义根的变量,您可以为每个url添加前缀。 -
如何使用变量来定义根?这就是我一直试图找到的:(
-
获取文档根目录请参考这里。 stackoverflow.com/questions/15211231/…
-
你能给我一个例子,如何在 href 中做到这一点:( php $indexURL = ('project/*'); ?>@joroen 我尝试使用绝对 url,但是当我在 ticket.php 页面中时,然后返回 index.php,url 卡在 /tickets/index.php 中。 Index.php 在 /ticket/ 之外