Go Back   CP Web Hosting - reseller hosting > Server Scripting > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-22-2007, 04:51 AM
Junior Member
 
Join Date: May 2007
Posts: 2
Default constant to be case insensitive

Hi,

I have a developed a web based application using PHP, for using the application, user has to get logged in, I have defined the user as a constant value using
define().
Can we make it case-insensitive, as sometimes user types, JIM, jim, Jim, so it gives an error message, as the user does not match.
Reply With Quote
  #2 (permalink)  
Old 06-22-2007, 04:55 AM
Junior Member
 
Join Date: Apr 2007
Posts: 3
Default

Well, define() optionally accepts a third boolean argument that determines whether the constant name should be case insensitive. By default, constants are case sensitive, but by passing true to the define() function you can change this behavior. So, if we were to set up our USER constant in this way

Define ("USER", "JIM", true);


we could access its value without worrying about case. So

print User;
print usEr;
print USER;


would all be equivalent.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:00 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0