You have to define first and then you can include any php file with SERVER_ROOT. if you are using URL without extension or you want to call a php file with slash e.g. (http://xyz.com/services/web) then you can use base url, so every php plugin should include with baseURL so it have no effects of page URL change.
- Define base url:123<?phpdefine ('BASE_URI', '/inhouse-projects/xyz/website/web/'); //remote path to root folder?>
- Include with base URL:1<?php include($_SERVER['DOCUMENT_ROOT'].BASE_URI."plugin/slider/index.php"); ?>1<img src="<?php echo BASE_URI."images/services/wes-logo.png"; ?>" align="left">1<script src="<?php echo BASE_URI."js/responsiveslides.min.js"; ?>"></script>1<a class="active homer" href="<?php echo BASE_URI."home.html"; ?>" style="color:#FFF;"> Home</a>1<a class="active homer" href="<?php echo BASE_URI."home"; ?>" style="color:#FFF;"> Home</a>
Note: you can simply define BASE_URI in a saperate file baseURL.php and include in Index.php, and you can use include with base URL.in every page.
Syntax
1 | define(name,value,case_insensitive) |
Parameter | Description |
---|---|
name | Required. Specifies the name of the constant |
value | Required. Specifies the value of the constant |
case_insensitive | Optional. Specifies whether the constant name should be case-insensitive. Possible values:
|