From 583db6300ef3a614f332d616961884f111bc6511 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Wed, 12 Jul 2017 07:55:09 +0000 Subject: [PATCH] getopts: substr in PHP7 has not the same result as PHP5. git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3807 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- getopts.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/getopts.php b/getopts.php index aae5dbc..b1e03e0 100644 --- a/getopts.php +++ b/getopts.php @@ -88,7 +88,8 @@ class getopts else $long = array (); } - if (substr ($short, 0, 1) !== false && $short[0] === ":") + if (substr ($short, 0, 1) !== false && substr ($short, 0, 1) !== "" && + $short[0] === ":") throw new \Exception ("Short option can't start by semi-colon", 500); if ((strpos ($short, ":") !== false || strpos (implode ($long), ":") !== false) && @@ -109,7 +110,8 @@ class getopts $short = $matches[0]; foreach ($short as $key=>$s) { - if (substr ($s, 1) !== false && substr ($s, 1) !== ":") + if (substr ($s, 1) !== false && substr ($s, 1) !== ":" && + substr ($s, 1) !== "") throw new \Exception ( "Short parameter is invalid : only one letter allowed", 500); $short[$key] = "-".$s;