I am overriding the value of the variable, looks simple.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

I am overriding the value of the variable, looks simple.

Post by lovelf »

Hi, I want to give a value to a variable if a user is coming from certain link that sets the value of $currency to ".php?c=c" but if the user is not coming from that link I want the default value set to nothing, "".

With the code I have I override the value of currency when I try to set a default value.

Code: Select all

<?php
switch($_GET['c']) {
case "c":
$currency = "?c=c";
break;
default:
$currency = "";
break;
}
?>
What should I do to make it work?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: I am overriding the value of the variable, looks simple.

Post by josh »

Whats wrong with the code you posted?
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Re: I am overriding the value of the variable, looks simple.

Post by lovelf »

When I call $currency it takes the value "" nothing even if I add on the url "?c=c", the second "$currency" on the code sets the value for $currency again, to "" not only by default but even when the switch should set a "?c=c" as a value for $currency.
lovelf
Forum Contributor
Posts: 153
Joined: Wed Nov 05, 2008 12:06 am

Re: I am overriding the value of the variable, looks simple.

Post by lovelf »

Nevermind, it does work. :crazy:
Post Reply