Are regex's allowed in PHP switch/case statements and how to use them ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Yes, but you should use this technique to avoid issues when the switch argument evals to
false
:Switch-case statement works like if-elseif.
As well as you can use regex for if-elseif, you can also use it in switch-case.
can be coded as
Hope this helps.
No or only limited. You could for example switch for
true
:This basically gives you an
if-elseif-else
statement, but with syntax and might ofswitch
(for example fall-through.)