Welcome Guest, Not a member yet? Register   Sign In
Maybe you can help, Global variables?
#3

[eluser]InsiteFX[/eluser]
Hi,

Code:
you have

<a href='&lt;?=base_url()?&gt;this/is/a/link'>blah</a>

should be

<a href='&lt;?=base_url();?&gt;this/is/a/link'>blah</a>

Your missing the semi-colon

As far as adding your own just add it to the config.php file or you can do it like this in constants.php these are submitted by users on this forum so no credit to me.

Code:
/*
|--------------------------------------------------------------------------
| Docment root folders
|--------------------------------------------------------------------------
|
| These constants use existing location information to work out web root, etc.
|
*/

// Base URL (keeps this crazy sh*t out of the config.php
if (isset($_SERVER['HTTP_HOST']))
{
    $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $base_url .= '://'. $_SERVER['HTTP_HOST'];
    $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

    // Base URI (It's different to base URL)
    $base_uri = parse_url($base_url, PHP_URL_PATH);

    if (substr($base_uri, 0, 1) != '/')
    {
        $base_uri = '/'.$base_uri;
    }

    if (substr($base_uri, -1, 1) != '/')
    {
        $base_uri .= '/';
    }
}
else
{
    $base_url = 'http://localhost/';
    $base_uri = '/';
}

// Define these values to be used later on
define('BASE_URL', $base_url);
define('BASE_URI', $base_uri);
define('APPPATH_URI', BASE_URI.APPPATH);
define('ASSETS_URL', BASE_URL."assets/");
define('IMAGES_URL', ASSETS_URL."images/");
define('CSS_URL', ASSETS_URL."css/");
define('JS_URL', ASSETS_URL."js/");

// We dont need these variables any more
unset($base_uri, $base_url);

Enjoy
InsiteFX


Messages In This Thread
Maybe you can help, Global variables? - by El Forum - 10-02-2009, 01:49 PM
Maybe you can help, Global variables? - by El Forum - 10-02-2009, 02:45 PM
Maybe you can help, Global variables? - by El Forum - 10-02-2009, 02:48 PM
Maybe you can help, Global variables? - by El Forum - 10-02-2009, 02:50 PM
Maybe you can help, Global variables? - by El Forum - 10-02-2009, 02:56 PM
Maybe you can help, Global variables? - by El Forum - 10-03-2009, 04:05 AM
Maybe you can help, Global variables? - by El Forum - 10-03-2009, 04:56 AM
Maybe you can help, Global variables? - by El Forum - 10-03-2009, 08:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB