random1 Posted March 22, 2008 Share Posted March 22, 2008 Hey All, I've got one file: home.php which includes another file "config.php". config.php declares a constant TEST_CONSTANT with the value "test only". in home.php I echo out TEST_CONSTANT and don't get "test only" but it prints out "TEST_CONSTANT". What's going on? I thought that Constants where global. Link to comment https://forums.phpfreaks.com/topic/97349-constants/ Share on other sites More sharing options...
kenrbnsn Posted March 22, 2008 Share Posted March 22, 2008 Please post the code your using. Ken Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-498130 Share on other sites More sharing options...
Kieran Menor Posted March 22, 2008 Share Posted March 22, 2008 Could the problem be that you are doing echo "TEST_CONSTANT"; rather than echo TEST_CONSTANT; ? Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-498132 Share on other sites More sharing options...
mVeliki Posted March 22, 2008 Share Posted March 22, 2008 Add in begin of script: error_reporting(E_ALL); It is posible that you tray to read that constant before you initialize it. Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-498226 Share on other sites More sharing options...
random1 Posted March 23, 2008 Author Share Posted March 23, 2008 Upon restart of my PC it just started working. How can I get the following accuracy for a large float number in a PHP constant? define("CONSTANT_PI", 3.141592653589793238462643383279); It prints out as: 3.14159265359 Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-499009 Share on other sites More sharing options...
marklarah Posted March 24, 2008 Share Posted March 24, 2008 round() Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-499108 Share on other sites More sharing options...
Barand Posted March 24, 2008 Share Posted March 24, 2008 <?php define("CONSTANT_PI", '3.141592653589793238462643383279'); $radius = 10; $circum = bcmul($radius*2, CONSTANT_PI, 30); echo $circum; // --> 62.831853071795864769252867665580 ?> Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-499129 Share on other sites More sharing options...
random1 Posted March 26, 2008 Author Share Posted March 26, 2008 Thanks, works like a charm Link to comment https://forums.phpfreaks.com/topic/97349-constants/#findComment-500874 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.