Tutorial 14 - PHP Switch Statement

preview_player
Показать описание
Robert explains how to create and use PHP switch statements.
Рекомендации по теме
Комментарии
Автор

hi great tut,
Can I ask, how will swtich move to case 2:

$payer_email = $_POST['payer_email'];
switch ($payer_email) {
case 1:
$query = mysql_query("SELECT * FROM tests WHERE payer_email='$payer_email'");
if(mysql_num_rows($query) > 0 ) { //check if there is already an entry for that username
echo "Customer has been blacklisted!";
break;

case 2: check different database for same payer_email

How will this work?
Thanks

scaranna
Автор

You dont need a break statement at the end of the default case, think about it, it doesnt make any sense. There is nothing left to fall through after the default so why break it?

phixphixation
Автор

very good! Codeacademy.com is great but it didnt explain it this well. thanks!

ambull