简体   繁体   中英

How to define the path in PHP using include or best practices

HI all

i am working on my brother site where he got "BreadCrumbs.php" on "publich_html" where index.html there also.

in public_html , i have few folder like "About Us", "career" and html file are in there as well. Now when i am putting "BreadCrumbs.php" link to Index.html file, it show the result, but when i am putting the same link to (ie about us.html which is in 'About us" Folder, its not working.

i am just wondering how i should define the include path so it works with the Folder as well. like this ...

Public_html
|
|__ index.html
|__ BreadCrumbs.php
|__ About Us > aboutus.html (File is in the Folder) |
|__ Career > career.html (File is in the Folder)

little help is really appriciate.

to add to my post i ahve this code

include_once('class.breadcrumb.inc.php');  
$breadcrumb = new breadcrumb;
echo "<p>".$breadcrumb->show_breadcrumb()."</p>";

its only work with index.html file. Not for other file which is are in the folders

thanks

I use the following to overcome the problem:

$about = HTTP_SERVER . 'folder/about.html';

The HTTP_SERVER will transform your link from about.html to http://www.yourhost.com/about.html

Note: Unless you are using Mod Rewrite to transform a php extension to html then you will need to have PHP code in only pages with the php extension (*.php).

You may consider the directory structure and include from a deeper level.

In public_html: include("./class.breadcrumb.inc.php");

In the subfolders: include("../class.breadcrumb.inc.php");

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM