Re: [PHP] Upper and lower case.
LOL got a reply to this before i ever got the message my self ... - Original Message - From: Philip J. Newman [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, March 02, 2003 10:56 AM Subject: [PHP] Upper and lower case. Question: is it better to store user names as upper and lower case? should they bee converted to one case? I have a script the checks for names and ... Mark is not the same as mark, or MaRk ... is there a way of making a string into lower case? -- Philip J. Newman. Head Developer [EMAIL PROTECTED] +64 (9) 576 9491 +64 021-048-3999 -- Friends are like stars You can't allways see them, but they are always there. -- Websites: PhilipNZ.com - Design. http://www.philipnz.com/ [EMAIL PROTECTED] Philip's Domain // Internet Project. http://www.philipsdomain.com/ [EMAIL PROTECTED] Vital Kiwi / NEWMAN.NET.NZ. http://www.newman.net.nz/ [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Upper and lower case.
is it better to store user names as upper and lower case? should they bee converted to one case? Store it where? It depends if the place you store it in and the comparisons there are going to be case sensitive or not. Most database fields are going to be case sensitive while a PHP comparison will not be. I have a script the checks for names and ... Mark is not the same as mark, or MaRk ... In PHP when you test with an equal to (==) they are not the same. You can use the strcasecmp() function to compare string case insensitively, though. In a general database VARCHAR field, they would be the same. is there a way of making a string into lower case? Strtolower() ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Upper or Lower Case
Hi Taz, What happens if they type NeO, or NEO, or nEo, or neO (etc)? ;) Also, if you're using this in a large application (or intend to in the future), are you going to type out all of the names as you have done with the neo example? Bjorn's method is much better, and you're better off getting into good practice early. James Tarrant Costelloe [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Ok thanks, I found jons way the easiest: if ($name == neo || $name == Neo) -Original Message- From: Bjorn Van Simaeys [mailto:[EMAIL PROTECTED]] Sent: 07 August 2001 16:24 To: [EMAIL PROTECTED] Subject: Re: [PHP] Upper or Lower Case Hi, I have run accross this problem too, and I solve it this way: if(strtolower($name1) == strtolower($name2)) I compare both variables in lower case, this way capitals don't matter at all. Greetz, Bjorn Van Simaeys www.bvsenterprises.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Upper or Lower Case
What happens if they type NeO, or NEO, or nEo, or neO (etc)? ;) Also, if you're using this in a large application (or intend to in the future), are you going to type out all of the names as you have done with the neo example? Bjorn's method is much better, and you're better off getting into good practice early. Who mentioned anything about typing? In the example given it was a hardcoded string. Jon Farmer Systems Programmer Entanet International Ltd www.enta.net Tel 01952 428969 Mob 07968 524175 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Upper or Lower Case
On 07-Aug-2001 Bjorn Van Simaeys wrote: Hi, I have run accross this problem too, and I solve it this way: if(strtolower($name1) == strtolower($name2)) I compare both variables in lower case, this way capitals don't matter at all. if (0 == strcasecmp('neo', $name)) // why didn't the call this stricmp ? echo 'matched'; if eregi('^neo$', $name) echo 'matched also'; Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Upper or Lower Case
Also keep in mind that sometimes spaces find their ways into the string and using trim() will get rid of them. Something like : if (strcasecmp('neo',trim($name)) == 0) { echo 'You chose our Neo line of goods, way to go!'; } Not to say spaces randomly attach to strings :-) but to be safe, I'm usually a trim freak. I Love to trim! Regards, Philip On Tue, 7 Aug 2001, Don Read wrote: On 07-Aug-2001 Bjorn Van Simaeys wrote: Hi, I have run accross this problem too, and I solve it this way: if(strtolower($name1) == strtolower($name2)) I compare both variables in lower case, this way capitals don't matter at all. if (0 == strcasecmp('neo', $name)) // why didn't the call this stricmp ? echo 'matched'; if eregi('^neo$', $name) echo 'matched also'; Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Upper or Lower Case
I must agree with Don that strcasecmp is the best way to go. Combined with the 'trim' function this is completely foolproof. Thanks, Don! Bjorn Van Simaeys www.bvsenterprises.com --- Don Read [EMAIL PROTECTED] wrote: On 07-Aug-2001 Bjorn Van Simaeys wrote: Hi, I have run accross this problem too, and I solve it this way: if(strtolower($name1) == strtolower($name2)) I compare both variables in lower case, this way capitals don't matter at all. if (0 == strcasecmp('neo', $name)) // why didn't the call this stricmp ? echo 'matched'; if eregi('^neo$', $name) echo 'matched also'; Regards, -- Don Read [EMAIL PROTECTED] -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]