note 38106 deleted from control-structures.switch by crell
| From: | crell@php.net | Date: | Mon, 27 Jun 2022 20:37:52 +0000 |
| Subject: | note 38106 deleted from control-structures.switch by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218633@lists.php.net to get a copy of this message | ||
Note Submitter: jon
----
In response to the entry by "kriek at jonkriek dot com", I think you would probably be
better of doing this:
<?php
// ensure $_GET['go'] is set, an integer, and not 0
// then, set nav number; default to 1
$nav = ( isset($_GET['go']) && (intval($_GET['go']) ==
$_GET['go']) && $_GET['go'] ) ?
intval($_GET['go']) : 1;
// format navigation string and include
include(sprintf("Page%02d.php",$nav));
?>
... as oppposed to the switch setup you recommended, which is limited to the number of cases you
specify...