how to declare img root in php for css files to find images

Go down

how to  declare img root in php for css files to find images Empty how to declare img root in php for css files to find images

Post by jamied_uk on 22nd November 2013, 14:36

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';
jamied_uk
jamied_uk
Admin

Posts : 2471
Join date : 2010-05-09
Age : 36
Location : UK

http://address-shortner.co.uk

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum