Detri Amelia Chandra
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor
No Result
View All Result
Detriamelia.com
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor
No Result
View All Result
Detriamelia.com
No Result
View All Result

8. PHP Switch Statement

15/01/2020
in PHP, Programming
PHP Switch Statement

PHP Switch Statement

Switches are not much different from If Else. Both of them describe conditions. The switch statement is used to perform different actions based on different conditions. Please pay attention and practice the explanation below.
The PHP Switch Statement
Use the switch statement to select one of many blocks of code to be executed.
This is the manner by which it works: First we have a solitary articulation n (regularly a variable), that is assessed once. The estimation of the articulation is then contrasted and the qualities for each case in the structure. In the event that there is a match, the square of code related with that case is executed. Use break to keep the code from running into the following case consequently. The default proclamation is utilized if no match is found.
See the example below :
[the_ad id=”651″]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$favcolor = "red";
switch ($favcolor) {
    case "red":
        echo "Your favorite color is red!";
        break;
    case "blue":
        echo "Your favorite color is blue!";
        break;
    case "green":
        echo "Your favorite color is green!";
        break;
    default:
        echo "Your favorite color is neither red, blue, nor green!";
}
?>

 

Tags: PHP
ShareTweetShare

Related Posts

Learn Python Basics for Beginners: Easy Ways to Understand the Python Programming Language
Python

Learn Python Basics for Beginners: Easy Ways to Understand the Python Programming Language

Python is a high-level programming language that can be used to create a wide range of applications. Python was created...

09/08/2023
Database Table Relations Using Join Operations and the Classical Model
Belajar PHP

Database Table Relations Using Join Operations and the Classical Model

MySQL is a highly popular relational database in today's programming world. With features that allow for table-to-table relationships, MySQL databases...

09/08/2023
PHP Forms - Validation With Required Fields
PHP

14. PHP Forms – Validation With Required Fields

Hi everyone, this time we will discuss about PHP Validation using the Required Field. Not many people know, it turns...

15/02/2020
PHP Form Handling
PHP

13. New Performing PHP Form Handling

Detriamelia.Com - Running form functions in PHP is not difficult. By using the $ _POST and $ _GET methods it...

13/02/2020
Next Post
PHP Loop (While, For, Foreach) Definition and Example

9. PHP Loop (While, For, Foreach) Definition and Example

PHP Function Definition and Example

10. PHP Function Definition and Example

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended

PHP Form Handling

13. New Performing PHP Form Handling

13/02/2020
Database Table Relations Using Join Operations and the Classical Model

Database Table Relations Using Join Operations and the Classical Model

09/08/2023
Understanding PHP Condition If Else, Elseif Statements

7. Understanding PHP Condition If Else, Elseif Statements

15/01/2020
PHP Loop (While, For, Foreach) Definition and Example

9. PHP Loop (While, For, Foreach) Definition and Example

15/01/2020

Instagram Feed

    The Instagram Access Token is expired, Go to the Customizer > JNews : Social, Like & View > Instagram Feed Setting, to refresh it.
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
Detriamelia.Com

© 2022 Detri Amelia Chandra - IT Tips and Programming Tutorials.

No Result
View All Result
  • HOME
  • GIS
  • HTML
  • Bootstrap
  • CSS
  • Javascript
  • Ubuntu
  • Useful Tools
    • URL Redirect Tool
    • URL Download Encryptor