Uldeens Posted March 8, 2006 Report Share Posted March 8, 2006 Vajag parbaudit mainiigo vai tas ir cipars vai nee. Linkaa var but padots tikai cipars tiko tur ir burti exit scenaariju. Sorry ka prasu pasham nevelna nesanaak. Shis neiet: <? $mainiigais=$_request['mainiigais']; if(is_int($mainiigais)) { require_once("main.php"); } else { require_once("error.html")"; } ?> Man tie if un else besii araaa ir kads labaaks variants ?? Paldies. Link to comment Share on other sites More sharing options...
bubu Posted March 8, 2006 Report Share Posted March 8, 2006 Tak cilvēk izlasi dokumentāciju! is_int pārbauda vai mainīgā datu tips ir integer, nevis vai strings sastāv no cipariem! Tev vajag ctype_digit fju izmantot: <?php $mainiigais=$_request['mainiigais']; require_once(ctype_digit($mainiigais) ? "main.php": "error.html"); ?> P.S. Lūdzu nākamreiz liec savu kodu bbtagos, šoreiz tavā vietā to izdarīju! Link to comment Share on other sites More sharing options...
john.brown Posted March 8, 2006 Report Share Posted March 8, 2006 (edited) Un laikam tak ar $_request arī neies, ja tik tas nav tevis definēts variablis. Varbūt domāji $_REQUEST? Edited March 8, 2006 by john.brown Link to comment Share on other sites More sharing options...
andrisp Posted March 8, 2006 Report Share Posted March 8, 2006 Vēl jau arī ir is_numeric(). Link to comment Share on other sites More sharing options...
bubu Posted March 8, 2006 Report Share Posted March 8, 2006 andrisp: is_numeric neder. Autoram vajag TIKAI ciparus, nevis 0xFF vai 1e-23 arī uzskatīt par derīgiem. Link to comment Share on other sites More sharing options...
Analgiins Posted March 9, 2006 Report Share Posted March 9, 2006 es daru shitaa: if (preg_match('/^\d+$/', $str)) { // ir tikai cipari } else { // nav tikai cipari } Link to comment Share on other sites More sharing options...
Delfins Posted March 9, 2006 Report Share Posted March 9, 2006 Analgiins, labāk `ereg` izmanto šādiem prastiem gadījumiem Link to comment Share on other sites More sharing options...
Analgiins Posted March 9, 2006 Report Share Posted March 9, 2006 Delfins, kaapeec? Link to comment Share on other sites More sharing options...
GedroX Posted March 9, 2006 Report Share Posted March 9, 2006 Analgiins, labāk `ereg` izmanto šādiem prastiem gadījumiem Note: preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg(). Liekās, ka preg tomēr ir ātrāks... Vai elementāriem gadījumiem ir otrādi? Link to comment Share on other sites More sharing options...
bubu Posted March 9, 2006 Report Share Posted March 9, 2006 Jūs jokaini cilvēki esat.. Ar lielgabalu pa zvirbuļiem gribat šaut. No regexpi gan te nekādas jēgas. Link to comment Share on other sites More sharing options...
Delfins Posted March 9, 2006 Report Share Posted March 9, 2006 ja zvirbuļu daudz, varbūt pat arī vajag šaut ar lielgabalu :) Link to comment Share on other sites More sharing options...
Recommended Posts