Command-Line Scripts
Option Values
Model a command-line option that carries a numeric value.
Option Values
option_value.php
<?php
$limit = ;
$option = "--limit";
$accepted = $limit >= 1 && $limit <= 20;
$status = $accepted ? "accepted" : "rejected";
echo "option=" . $option . "\n";
echo "limit=" . $limit . "\n";
echo "status=" . $status . "\n";
<?php
$limit = ;
$option = "--limit";
$accepted = $limit >= 1 && $limit <= 20;
$status = $accepted ? "accepted" : "rejected";
echo "option=" . $option . "\n";
echo "limit=" . $limit . "\n";
echo "status=" . $status . "\n";
<?php
$limit = ;
$option = "--limit";
$accepted = $limit >= 1 && $limit <= 20;
$status = $accepted ? "accepted" : "rejected";
echo "option=" . $option . "\n";
echo "limit=" . $limit . "\n";
echo "status=" . $status . "\n";
option-value
Some options are pairs: an option name and the value that follows it. The script can validate the value before using it.