在我的网站和php-include函数中设置正确的相对路径
I have a basic question and since I am a noob with php it is difficult to dig through the thousands of questions you already answered...So I ask you for further help, sorry...
I just need to recall header.php
into HTML pages. The website structure look like this:
-index.php
-header.php
-style.css
-articles/article1.php
-image/header.jpg
For index.php
I used
<?php include 'header.php'; ?>
and everything works fine!
The problem arises with pages like article1.php
, i.e. for pages that are not in the root. I tried with
<?php include ('http://localhost/phpBB3/header.php'); ?>
because I am working locally rightnow, and 'localhost/phpBB3' is the root) but it does not work. Also I tried with
<?php include ('/header.php'); ?>
or with
<?php include ('../header.php'); ?>
barely understanding the real meaning of all these ./
(I know, I know, shame on me!)
Moreover, the header.php
points to both style.css
and header.jpg
(the latter inside the image
folder) and refers to ids and classes defined, of course, in the style.css
.
I think I may have some problem in their path as well.
How can I put things in order?
Any help is greatly appreciated! Mya
我有一个基本的问题,因为我是一个使用php的菜鸟,很难通过成千上万的问题挖掘你 已经回答了......所以我请求你们进一步的帮助,对不起...... p>
我只需要将 一切正常!
因为我正在本地工作,而'localhost / phpBB3'是根)
但它不起作用。
我也试过
或 p>
几乎不了解所有这些 此外, 如何整理好东西? p>
非常感谢任何帮助!
Mya p>
div> header.php code>召回到HTML页面中。 网站结构如下所示: p>
-index.php
-header.php
-style.css
-articles / article1.php
-image / header.jpg
code> pre>
index.php code>我用过 p>
&lt;? php包含'header.php'; ?&gt;
code> pre>
article1.php code>等页面出现问题,即对于不在的页面 根。 我试过 p>
&lt;?php include('http://localhost/phpBB3/header.php'); ?&gt;
code> pre>
&lt;?php include('/ header.php'); ?&gt;
code> pre>
&lt;?php include('../header.php' ); ?&gt;
code> pre>
./ code>的真正含义(我知道,我知道,对我感到羞耻!)
header.php code>指向
style.css code>和
header.jpg code>(后者) 在
image code>文件夹中)并且引用了当前在
style.css code>中定义的id和类。
我想我的路径也可能有问题。 p>