InTrance Posted November 21, 2011 Report Share Posted November 21, 2011 Sveiciens/Labs vakars visiem. Sākšu, stāstīt savu bēdu stāstu, atradu vecu lapeli savu, izlēmu to optimizēt un salabot, viss jau būtu jauki, ja ne, tas ka, nevaru iebraukt, kā uzstādīt Defaultu variabli, ja Linkā, ir atstāts šāds brīnums, &id= Nesakiet, google or ko tādu, skatjos gan empty/gan isset variantus pat apsvēru domu redirektot ja tukš, bet nu nesanāk, kā vēlos.. Principā, kods kas atbild par to ir man: if(!isset($_GET['id'])) exit; else $id = $_GET['id']; if (!preg_match("|^[\d]+$|", $id)){ exit ("<p>Ak vai ;[</p>"); } Un idejiski vēlos if isset, iemet cipariņu 1, exit vietā.. Būtu pateicīgs, ja atrastos, kāds, kas palīdzētu, cerams ka sapratāt. Quote Link to comment Share on other sites More sharing options...
zintis8789 Posted November 21, 2011 Report Share Posted November 21, 2011 if(empty($_GET['id'])) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 21, 2011 Report Share Posted November 21, 2011 $id = !empty($_GET['id']) ? $_GET['id'] : 1; Quote Link to comment Share on other sites More sharing options...
marcis Posted November 21, 2011 Report Share Posted November 21, 2011 @daGrevis šitā būs ātrāk visādā ziņā :D $id = empty($_GET['id']) ? 1 : $_GET['id']; Quote Link to comment Share on other sites More sharing options...
Mr.Key Posted November 21, 2011 Report Share Posted November 21, 2011 (edited) $_GET['id'] || $_GET['id'] = 1; echo $_GET['id']; Edited November 21, 2011 by Mr.Key Quote Link to comment Share on other sites More sharing options...
briedis Posted November 21, 2011 Report Share Posted November 21, 2011 $_GET['id'] || $_GET['id'] = 1; echo $_GET['id']; Notice: undefined index id Quote Link to comment Share on other sites More sharing options...
Mr.Key Posted November 21, 2011 Report Share Posted November 21, 2011 Tas nekas, viņš definē anyway. Quote Link to comment Share on other sites More sharing options...
briedis Posted November 21, 2011 Report Share Posted November 21, 2011 Tas nekas, viņš definē anyway. Nu nez, kāda starpība, jākodē ir tā, lai nebūtu neviena notice'a :) vismaz tāda ir mana filosofija... Quote Link to comment Share on other sites More sharing options...
Mr.Key Posted November 21, 2011 Report Share Posted November 21, 2011 (edited) nu ok, pūristiem: array_key_exists('id', $_GET) && $_GET['id'] || $_GET['id'] = 1; ja vajag obligāti ciparu, tad: $id = 1; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; } (is_numeric novērš id=555xxxxaaa pārveidošanu par $id=555, kas būtu, ja tikai isset un (int)) Edited November 21, 2011 by Mr.Key Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 22, 2011 Report Share Posted November 22, 2011 Mr.Key, varbūt vienkāŗsi tā, ka es vai Mārcis uzrakstīja? :D Quote Link to comment Share on other sites More sharing options...
Kavacky Posted November 22, 2011 Report Share Posted November 22, 2011 Kas tās par pretdievīgām abominācijām, ko Mr. Key sarakstīja? Quote Link to comment Share on other sites More sharing options...
Mr.Key Posted November 22, 2011 Report Share Posted November 22, 2011 Mr.Key, varbūt vienkāŗsi tā, ka es vai Mārcis uzrakstīja? :D Bet protams, kas gan liedz izmantot ērtāko variantu? Kas tās par pretdievīgām abominācijām, ko Mr. Key sarakstīja? Esmu ateists - plurālists. Quote Link to comment Share on other sites More sharing options...
waplet Posted November 22, 2011 Report Share Posted November 22, 2011 apache konfigurācijā , register_globals = off Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 22, 2011 Report Share Posted November 22, 2011 apache konfigurācijā , register_globals = off Kādā sakarā? Quote Link to comment Share on other sites More sharing options...
Mr.Key Posted November 22, 2011 Report Share Posted November 22, 2011 Profilaksei. :) 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.