Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.