Constants Help - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Constants Help (/showthread.php?tid=34928) |
Constants Help - El Forum - 10-14-2010 [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? Constants Help - El Forum - 10-14-2010 [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!'); Constants Help - El Forum - 10-14-2010 [eluser]CI_Newb[/eluser] is there a different way to call TEST_VAR? I tried echo'ing it and it didn't work. Constants Help - El Forum - 10-14-2010 [eluser]tonanbarbarian[/eluser] Code: <?php echo TEST_VAR; ?> Constants Help - El Forum - 10-14-2010 [eluser]CI_Newb[/eluser] Awesome, works like a charm! Thanks for the help Constants Help - El Forum - 10-14-2010 [eluser]danmontgomery[/eluser] http://php.net/manual/en/language.constants.php |