Changes

Quick Reference for PHP

823 bytes added, 20:48, 18 April 2014
/* Switch is the Equivalent of Case */
The following lines were added (+) and removed (-):
     print "QUERYSTRING= $qString<BR>";     <nowiki>print "QUERYSTRING= $qString<BR>";</nowiki>     if ($qString == "") $qString = "home";     <nowiki>if ($qString == "") $qString = "home";</nowiki>       ?><i>Viewing the HOME PAGE</i></a> <?       <nowiki>?><i>Viewing the HOME PAGE</i></a> <?</nowiki>       ?><i>Viewing some other page</i></a> <?       <nowiki>?><i>Viewing some other page</i></a> <?</nowiki>The line with preg_replace protects against known query string exploits.  The null assignment could be done better, however, the example is for syntax purposes.== Switch is the Equivalent of Case == <nowiki><?</nowiki> <nowiki>switch ($i) {</nowiki> <nowiki>    case 0:</nowiki> <nowiki>        echo "i equals 0";</nowiki> <nowiki>        break;</nowiki> <nowiki>    case 1:</nowiki> <nowiki>        echo "i equals 1";</nowiki> <nowiki>        break;</nowiki> <nowiki>    case 2:</nowiki> <nowiki>        echo "i equals 2";</nowiki> <nowiki>        break;</nowiki> <nowiki>    default:</nowiki> <nowiki>      echo "i is not equal to 0, 1 or 2";</nowiki> <nowiki>}</nowiki> <nowiki>?></nowiki>Or with string variables case "apple":
Bureaucrat, administrator
16,192
edits