English 中文(简体)
• 如何保持与PHP的路径结构?
原标题:How to preserve path structure with PHP include?

我有一个工具barMenu.php,从根子里使用 director(“cs”)。

我的所有其他项目组合形式都扎根,并计划重新组织我的所有项目组合,以转向一个称为“形”的脱硫工具barMenu.php。

After I move my PHP form to sub-directory, I can call this toolbarMenu.php by using include ex:

<?php include("../toolbar-top.php"); ?>

然而,由于该中心试图在形式夹中寻找手套,因而中断了道路。 我不想把车道从我的工具barMenu.php改为“.cs/file.cs”,因为Im也利用这个网站的网页,浏览根本的网页。

是否有办法保护工具barMenu.php在从另一个分流中从一种PHP表格中叫走时的 c路?

根基:

工具箱 Menu path:“toolbarMenu.php”

CSS 途径:“cs/cssFile.cs”

PHP 表格称为工具barMenu:“forms/form.php”

我希望我明确地提出问题:

感谢!

最佳回答

你们要么可以采用绝对的道路,例如:

<link rel="stylesheet" type="text/css" href="/mySite/css/file.css">

或者,如果你想保持其可携带性,则为相对途径设定动态的<代码><base>。 这样,你就可以把你的全部东西移至一个分行,而不必打断参考资料链接。

<!-- in HEAD -->
<base href="http://localhost/mySite/">
<link rel="stylesheet" type="text/css" href="css/file.css">
问题回答

你们有多种选择,可以取得预期结果:

  1. You can define a prefix variable/constant at the top of every page which you then use in all your includes/urls/etc.
  2. You can also use the <base> tag in your header pointing to the absolute URL to ../ so something like http://ys.cc/proj/ if your forms directory is http://ys.cc/proj/forms

您可以从以下几个方面撰写论文:

css/file.css

纽约总部

/css/file.css

这将在所有方面发挥作用。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签