I'm making a website that has a column called -News - , this column I call through include
. (you can imagine that it is an external file - news.php) , so far normal.
It turns out that on my site there are folders on other levels, for example:
- index.php
- news.php
- content / action / index.php
- content / material / index.php
- content / util / index.php
There are more or less 10 folders with the same structure.
On the main page ( index.php
), I am including the news.php as follows:
$path = "news.php" ;
include $path;
So far as normal.
It happens that when I call the same file in index that has sublevels, my URL loses the reference.
$path = "../../news.php" ;
include $path;
The news field appears on my pages, but when I click on a link the URL appears wrong. Here's an example below:
content/news/2018/acao/news/2018/index.php
I would like to know if there is something, which makes PHP , of the subfolders, return to the parent level (lets say so).
I tried to use $path = $_SERVER['DOCUMENT_ROOT'];
, but it did not work. dirname($path)
did not work either.
Of course PHP is correct in your reading, but if you can help me solve this problem, I'll be grateful.