how to declare img root in php for css files to find images
Page 1 of 1
how to declare img root in php for css files to find images
- Code:
http://stackoverflow.com/questions/7037959/css-root-directory
<base href="https://sitename.com/images/" />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function root_path() {
if(!preg_match("/^(http:\/\/)/", $_SERVER['HTTP_HOST'])) {
$server = "http://" . $_SERVER['HTTP_HOST'];
} else {
$server = $_SERVER['HTTP_HOST'];
}
if(!preg_match("/(\/)$/", $server)) $server = $server . '/';
$path = explode('/', dirname(htmlentities($_SERVER['PHP_SELF'])));
$path = $path[1];
if(!preg_match("/(\/)$/", $path)) $path = $path . '/';
return $server . $path;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ini_set('include_path', './' . PATH_SEPARATOR . "./common/". PATH_SEPARATOR . ini_get('include_path'));
or
set_include_path( implode( PATH_SEPARATOR, array(
$_SERVER['DOCUMENT_ROOT'],
get_include_path()
) ) );
then you can just do:
include 'common/header.php';
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum