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
kevrelland
Forum Commoner
Posts: 73 Joined: Mon Jan 08, 2007 7:41 am
Post
by kevrelland » Tue Jan 11, 2011 10:05 am
I can't seem to get this if working any ideas?
/If i have it like this
Code: Select all
if ($PriceList == "£0.00") {
$displayString = "<p class=\"price half_margin\">Free Event</p>";
} else {
$displayString = "<p class=\"price half_margin\">" . $PriceList . "</p>";
}
return $displayString;
the else statement works.
if I make it
Code: Select all
if ($PriceList != "£0.00") {
$displayString = "<p class=\"price half_margin\">Free Event</p>";
} else {
$displayString = "<p class=\"price half_margin\">" . $PriceList . "</p>";
}
return $displayString;
the if statement works.
The only thing i can think of is the $PriceList returns the pound symbol as a code, but i have tried £ and still the same result, is there anyway i can get $PriceList in a browser without any formatting?
Cheers
Kevin
TorMike
Forum Newbie
Posts: 17 Joined: Thu Feb 25, 2010 9:14 am
Post
by TorMike » Tue Jan 11, 2011 10:21 am
Your problem is probably the pound symbol as part of the variable. (sorry can't make a pound symbol).
Perhaps if $PriceList was a numeric value (15) then add the pound symbol when you display (sorry I'll use a dollar sign)
Code: Select all
If ($PriceList == 0)
{
$displayString = "<p class=\"price half_margin\">Free Event</p>";
} else {
$displayString = "<p class=\"price half_margin\">[color=#800000][b]$[/b][/color]" . $PriceList . "</p>";
}
return $displayString;
That way you don't have to worry about symbols, work with the value and add the symbol at display.
Last edited by
Benjamin on Tue Jan 11, 2011 10:48 am, edited 1 time in total.
Reason: Added [syntax=php] tags.
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Tue Jan 11, 2011 10:46 am
Slightly off-topic :
Code: Select all
<!-- £ or £ -->
£
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering