/    Sign up×
Community /Pin to ProfileBookmark

call a define by using a vairable ?

Hi,

Ok senario: –

I have a notice page that i can link to and i also have a define like this : –

[CODE]
define(‘NOTICE_1’, ‘Msg 1’)
define(‘NOTICE_2’, ‘Msg 2’)
[/CODE]

I refer to the notice page and put a $_get variable in to say the notice_id
How can i call the notice by using the $_
get???

So in a sence i want to display

NOTICE_$_GET[‘notice_id’]

so if the notice_id = 1 it will call the deifne NOTICE_1
but that obviously doesn’t work!?

Thanks
k0r54

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogOct 10.2005 — I believe you could use the constant() function for this. An untested example:
[code=php]
if(isset($_GET['notice_id']) and defined('NOTICE_'.$_GET['notice_id']))
{
$value = constant('NOTICE_'.$_GET['notice_id']);
}
else
{
# either set $value to default value or generate error, as appropriate
}
[/code]
Copy linkTweet thisAlerts:
@k0r54authorOct 11.2005 — worked a treat ? thanks nogdog
×

Success!

Help @k0r54 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...