Jump to content
Sign in to follow this  
jodunno

php case insensitive?

Recommended Posts

Dear members,

I have recently noticed something about php and my regex filter: a-z still allows A-Z. The same is true of a filename in php. I name a file hello.php and it is included if i call it as  Hello.php.

if (preg_match("/^[a-z\/\s_-]{3,116}$/i", $variable) === 0) { break(2); }

is my regex incorrect? i am trying to check an entire string for matching characters. I usually create an array as a key and say if not in array. However, i cannot create an array for this particular string which could contain over 100,000 possibilities. Thus the use of regex. Perhaps my regex is incorrect or php is case insensitive.

summary: the string Abc/Xyz gets through despite only regex of a-z. I would think that it should be A-Za-z. No?

Best wishes.

Share this post


Link to post
Share on other sites

haha, /i.

i am working with microvision today. man, that is funny!

wasted space on the server for this stupid post. My apologies.

Share this post


Link to post
Share on other sites
9 minutes ago, jodunno said:

The same is true of a filename in php

for this part of your question, it depends on the operating system. for a case-insensitive operating system, such as Windows, Hello.php and hello.php are the same. for a case-sensitive operating system, such as lunix, those are two different file names.

Share this post


Link to post
Share on other sites
3 hours ago, mac_gyver said:

for this part of your question, it depends on the operating system. for a case-insensitive operating system, such as Windows, Hello.php and hello.php are the same. for a case-sensitive operating system, such as lunix, those are two different file names.

wow! Thank you for this info! I really did not know that this is a Windows-specific situation. Your post has saved me a huge headache because my host will be a linux machine. Thus my website would not work correctly at launch because of this case mismatch in my code. Thank You, mac_gyver!

meantime, i am too tired to code today. I cannot believe that i missed the i modifier when i posted. alot like locking a door then asking why the door doesn't open. LOL!

Best wishes to all.

Share this post


Link to post
Share on other sites

Actually, Unix-like operating systems treat file names case-sensitively whereas Microsoft Windows is case-insensitive but, for most file systems, case-preserving. So for this reason you must not be getting desired output.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.