
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
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
- Related Articles
- Explain nested switch case in C language
- Switch case in Arduino
- How to use case-insensitive switch-case in JavaScript?
- What is Switch...case statement in JavaScript?
- Switch case statement in C
- Switch case calculator in JavaScript
- Switch Case in Python (Replacement)
- String in Switch Case in Java
- The String in Switch Case in Java
- CASE WHEN in PostgreSQL?
- Using range in switch case in C/C++
- How to implement switch-case statement in Kotlin?
- What is difference between using if/else and switch-case in C#?
- What is a switch case statement in Java and how to use it?
- Java program to generate a calculator using the switch case

Advertisements