Scrigroup - Documente si articole

Username / Parola inexistente      

Home Documente Upload Resurse Alte limbi doc  

AccessAdobe photoshopAlgoritmiAutocadBaze de dateCC sharp
CalculatoareCorel drawDot netExcelFox proFrontpageHardware
HtmlInternetJavaLinuxMatlabMs dosPascal
PhpPower pointRetele calculatoareSqlTutorialsWebdesignWindows

AspAutocadCDot netExcelFox proHtmlJava
LinuxMathcadPhotoshopPhpSqlVisual studioWindowsXml

Tutorial - Introduction to Switches


+ Font mai mare | - Font mai mic


Trimite pe Messenger
Tutorial - Creating and Using Views
Tutorial - Updating the data already in your database
Introduction to PHP
Tutorial - Checking your data for errors
Tutorial - Introduction to Indexes
Apache, PHP
Tutorial - Data Retrieval with PostgreSQL
Tutorial - Referential Integrity
Use PostgreSQL and PHP on Windows
Tutorial - Using Explain

Tutorial - Introduction to Switches  

Switches are very useful alternatives to really big if statements.

There isn't much of an introduction here, we'll jump right into them in detail.

switch ($a)

The first line:

switch ($a) ) is the same as break statement

} elseif ($a == 'b') ) is the same as break statement

} else

With our example, there's not a lot of difference, but when you get a few cases to test and each case needs lots of different

processing, using a switch makes sense, and looks cleaner (and easier to read).

Another handy feature of switches is to get multiple cases to do the same thing. How? By leaving out the 'break'

statements. So:

switch ($a)

will do the same for $a when it has the value of 'a' and 'b'.

How do we use them in a script? Anywhere where you either set a value, or values are set specifically (for example, radio


Here's a simple script to test our switch:


$a = 'a';

switch ($a)


Change the value of $a to test the switch. Pretty simple!

Politica de confidentialitate



Vizualizari: 499
Importanta: rank

Comenteaza documentul:

Te rugam sa te autentifici sau sa iti faci cont pentru a putea comenta

Creaza cont nou

Termeni si conditii de utilizare | Contact
© SCRIGROUP 2021 . All rights reserved

Distribuie URL

Adauga cod HTML in site