jodunno Posted June 24, 2020 Share Posted June 24, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310991-php-case-insensitive/ Share on other sites More sharing options...
jodunno Posted June 24, 2020 Author Share Posted June 24, 2020 haha, /i. i am working with microvision today. man, that is funny! wasted space on the server for this stupid post. My apologies. Quote Link to comment https://forums.phpfreaks.com/topic/310991-php-case-insensitive/#findComment-1579114 Share on other sites More sharing options...
mac_gyver Posted June 24, 2020 Share Posted June 24, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310991-php-case-insensitive/#findComment-1579115 Share on other sites More sharing options...
jodunno Posted June 24, 2020 Author Share Posted June 24, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310991-php-case-insensitive/#findComment-1579122 Share on other sites More sharing options...
Komal28 Posted July 24, 2020 Share Posted July 24, 2020 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. Quote Link to comment https://forums.phpfreaks.com/topic/310991-php-case-insensitive/#findComment-1580006 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.