shuka79 Posted June 28, 2010 Share Posted June 28, 2010 Hi guys, I have a php page that define a load of varibles in the format define('EX_1', 'example 1'); define('EX_2', 'something else'); this goes up to EX_10, when the page is displayed it list all the different links, and when one is click it will add ?show=1 to the url, so when the page loads it will show all the details for EX_1 The issue I am having is that it is not getting the details I have the following code echo EX_$_REQUEST['show']; but this just returns EX_1. If I put it in hard code echo EX_1; It will display example 1 on the page. Can any one see what I am missing? Thanks in advance for your help Cheers Shuka Link to comment https://forums.phpfreaks.com/topic/206094-defining-a-variable/ Share on other sites More sharing options...
premiso Posted June 28, 2010 Share Posted June 28, 2010 echo constant(EX_ . $_REQUEST['show']); The constant function is what you are going to need to use. You may also want to check if the variable is_defined before accessing it, given that show could be any number (either that or default show to something if it is not set / out of the range of valid values). Link to comment https://forums.phpfreaks.com/topic/206094-defining-a-variable/#findComment-1078356 Share on other sites More sharing options...
shuka79 Posted June 29, 2010 Author Share Posted June 29, 2010 cheers premiso, that worked a treat!! Link to comment https://forums.phpfreaks.com/topic/206094-defining-a-variable/#findComment-1078700 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.