Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Please explain what happens when PHP switch case executes case 0?
The PHP is a loosely typed language. When you match with case 0 the string matches with closest integer.
Let’s say we have the following switch expression −
switch ("match")
Now, we will match with case 0 −
case 0: echo " 0 with match"; break;
We will also match for non-zero case −
case "match": echo "match successful"; break;
Example
<!DOCTYPE html>
<html>
<body>
<?php
switch ("match") {
case 0:
echo " 0 with match";
break;
case "match":
echo "match successful";
break;
}
?>
</body>
</html>
Output
0 with match
Advertisements