daGrevis Posted March 11, 2010 Report Share Posted March 11, 2010 Sveikiņi, Vēlos uztaisīt tā, ka linku pamainot uz "page.php?mode=version" izvadās attiecīgais. Tas strādā, bet nestrādā tas, ka ja nekas nav noteikts ("page.php") -> tā pat izvadās "No mode defined.", kā arī, ja ir "page.php?mode" -> tas pats. Pēc koda ceru ka var saprast, un ceru, ka palīdzēsiet to pielabot... :) if($_GET['mode'] == null) { echo 'No mode defined.'; die(); } elseIf($_GET['mode'] == 'version') { echo 'It works!'; die(); } Quote Link to comment Share on other sites More sharing options...
2easy Posted March 11, 2010 Report Share Posted March 11, 2010 a man gan strādā tas, ka ja nekas nav padots, tad smuki izvadās 'No mode defined.' :)) Quote Link to comment Share on other sites More sharing options...
sandis_m Posted March 11, 2010 Report Share Posted March 11, 2010 Man arii strādā . Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 11, 2010 Author Report Share Posted March 11, 2010 Nu jā, 2easy, bet tā man tieši nevajag... Vajadzētu ta, ka ja nekas nav padots -> nekas nenotiek. Ja padots "page.php?mode", tad ir "No mode defined." utml.... :) Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted March 11, 2010 Report Share Posted March 11, 2010 Nu ja nekas nav padots tad ari ir jāizvadās 'No mode defined.' - kur tieši ir kļūda? Un labāk ir izmantot isset() nevis == null IMO. Quote Link to comment Share on other sites More sharing options...
2easy Posted March 11, 2010 Report Share Posted March 11, 2010 (edited) aaaaaa priekš tam jau ir isset() vai dažreiz arī is_null() ohh, rATRIJS 1st ;) Edited March 11, 2010 by 2easy Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 11, 2010 Author Report Share Posted March 11, 2010 @rATRIJS, ņemšu vērā, bet tas neatrisina problēmu... :( Quote Link to comment Share on other sites More sharing options...
2easy Posted March 11, 2010 Report Share Posted March 11, 2010 vispār jau tas tomēr atrisina gan problēmu :P Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 11, 2010 Author Report Share Posted March 11, 2010 Kurš to būtu domājis, atrisina gan... :D Paldies. if($_GET['mode'] == 'version') { echo 'Version 1.0.'; die(); } elseIf(isSet($_GET['mode'])) { echo 'No mode defined.'; die(); } Tagad jautājums #2. Ka lai panāk, ka ja tā saucamais "mode" ir definēts, bet definētais vārds nepastāv ("page.php?mode=undefined") -> izmest kļūdas paziņojumu. :) Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted March 11, 2010 Report Share Posted March 11, 2010 (edited) Pa vēlu jau (chrome nokārās (uz linux tas notiek reizi dienā :( )), bet reku tests uzvarai: Un par otro - tev tik atliek definēt visu iespējamo - kaut vai ar switch (piemērā nav switch - switch vari izmantot, lai daritu nepieciešamo): $possible_options = array("one", "two", "three"); if(in_array($_GET["mode"], $possible_options)) echo "success"; else echo "FAIL"; Edited March 11, 2010 by rATRIJS Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.