Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter global constant

Tags:

codeigniter

I have defined one variable inside the constants.php file of codeigniter but i want to know how to use that variable into the view file.

define('UPLOAD_PATH', "/var/www/vhosts/dev/htdocs/p/");

I want to use 'UPLOAD_PATH' variable in my view file but i dont know how to use it.

like image 972
user493619 Avatar asked Apr 25 '11 10:04

user493619


People also ask

How to define global constants in CodeIgniter in constant PHP?

Global Constant Using Constants.defined('MY_CONSTANT') || define('MY_CONSTANT', 'This is a global constant defined in Constants. php file');

What is ESC in CodeIgniter?

esc($string) ?>" /> If you use any of the form helper functions listed on this page, and you pass values as an associative array, the form values will be automatically escaped, so there is no need to call this function. Use it only if you are creating your own form elements, which you would pass as strings.


1 Answers

The same way you would use a constant in normal php?

echo UPLOAD_PATH; //would produce /var/www/vhosts/dev/htdocs/p/

So in your view file:

<html>
    <body>
        <?=UPLOAD_PATH?>
    </body>
</html>
like image 74
Dormouse Avatar answered Nov 07 '22 23:11

Dormouse