Welcome Guest, Not a member yet? Register   Sign In
Constants Help
#1

[eluser]CI_Newb[/eluser]
I've been trying to figure out how to use the constants.php file to load simple global variables that i need access to application wide but I can't figure out how to use it.

I tried adding to constants.php
Code:
$test_var = "HOPE YOU CAN SEE THIS!";

and tried using it on a view page
Code:
<?php echo $test_var; ?>

But all I got was a undefined variable error.

Can someone point me in the right direction?
#2

[eluser]WanWizard[/eluser]
That is not a constant, that's a normal variable. If you want to make it a constant:
Code:
define('TEST_VAR', 'HOPE YOU CAN SEE THIS!');
#3

[eluser]CI_Newb[/eluser]
is there a different way to call TEST_VAR?

I tried echo'ing it and it didn't work.
#4

[eluser]tonanbarbarian[/eluser]
Code:
<?php echo TEST_VAR; ?>
#5

[eluser]CI_Newb[/eluser]
Awesome, works like a charm!

Thanks for the help Smile
#6

[eluser]danmontgomery[/eluser]
http://php.net/manual/en/language.constants.php




Theme © iAndrew 2016 - Forum software by © MyBB