not being able to compare if($char=='«')

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
devendra-m
Forum Contributor
Posts: 111
Joined: Wed Sep 12, 2007 3:16 am

not being able to compare if($char=='«')

Post by devendra-m »

if($char=='«') is not working properly. $char contain the value '«'.But when i tried the condition it returns false.what might be the problem anybody have idea.
devendra-m
Forum Contributor
Posts: 111
Joined: Wed Sep 12, 2007 3:16 am

Post by devendra-m »

And I used utf-8 as default character set
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You sure that the character is not html-encoded (i.e. «)?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

try mb_strrpos() and see if you can find the one string in the other. Keep in mind though that you'll be looking for the offset 0, not a failure (FALSE). Since zero is falsy, you'll need to do a comparison with ===.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

try this instead then...

Code: Select all

if($char == char(174)) {
  echo "YO";
}
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

Someone else echos "yo" besides me? AWESOME.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I usually echo profane 4 letter words that aren't suitable here. Ironically I don't swear in my comments though... generally.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

=] nice. Yo is almost always what I use when just testing stuff out. That and $bob vars =P
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

$bob vars too?? Holy hell, it's mirror universe Kieran!
devendra-m
Forum Contributor
Posts: 111
Joined: Wed Sep 12, 2007 3:16 am

Post by devendra-m »

The problem has been solved. Thank you all for your reply.
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

astions wrote:I usually echo profane 4 letter words that aren't suitable here. Ironically I don't swear in my comments though... generally.
I've moved away from that and more towards generic words such as "Test" and "ABC". Every user of my site now refers to me as Mr. OMGLOL, being as I threw a die into some code that just happened to be sunk over to our live site by a programmer who didn't think anyone else was working at the time. Ah, good times. :)
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

I always echo "okay," "not okay," and "shazbot!" Depends on whether or not something was supposed to happen.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

I prefer var_dump(__FILE__ . ':' . __LINE__, $valueToDump)
Post Reply