0
I’m making a website that has a column called -News-, this column I call through the include
. (you can imagine that it is an external file - news.php), until then.
It turns out that on my site there are folders on other levels, for example:
- index php.
- news php.
- content/acao/index.php
- content/material/index.php
- content/util/index.php
There are about 10 folders with the same structure.
On the home page (index.php
), I’m including the news php. as follows:
$path = "news.php" ;
include $path;
So far normal.
Turns out when I call the same file we index that has sublevels, my URL misses the reference.
$path = "../../news.php" ;
include $path;
The field news appears on my pages, but when I click on a link to URL wrong. Following example below:
content/news/2018/acao/news/2018/index.php
I’d like to know if there’s anything PHP, back to the parent level (let’s say so).
I tried to use $path = $_SERVER['DOCUMENT_ROOT'];
, but it didn’t work. dirname($path)
also did not work.
Of course PHP is correct in its reading, but if you can help me to solve this problem, I would be grateful.
news.php is in the root folder of your project, and the $path that is giving error when giving include is within content/acao/index.php?
– David Alves
that’s right ! $path is in the share index...
– user2643885
Utilize
set_include_path('/path/to')
in their index php. or use the full pathinclude "/path/to/news.php";
or userewrite
(as a kind of friendly URL).– Valdeir Psr
cool... I’ll try what you said ... (y)
– user2643885