janchuxss Posted July 6, 2006 Report Share Posted July 6, 2006 (edited) Sveiki! Gribu uztaisīt tādu lietu - man ir links <a href="?go=ABC>ABC</a> un tālāk man ir switch: <?php switch ($_REQUEST['go']) { case $test: include ($test".php"); break; default: echo ("tirlii bums"); break; } ?> Un es gribu lai man parāda ABC.php Es ceru domu sapratāt :) vnk gribu spiežot uz linka lai man atver failu, kurš ir mainīgā $test vērtība un galā .php Un vai vispār tas ir iespējams? Un kā vispār to switchu rakstīt ar mainīgo? Paldies jau iepriekš :) Edited July 6, 2006 by janchuxss Link to comment Share on other sites More sharing options...
Toms Posted July 6, 2006 Report Share Posted July 6, 2006 http://www.google.lv/search?hl=lv&q=php+sw...%C5%A1ana&meta= Un tas ir iespējams. REQUEST vietā labāk izmantot GET Link to comment Share on other sites More sharing options...
Klez Posted July 7, 2006 Report Share Posted July 7, 2006 (edited) case $test: include ($test . ".php"); break; http://lv.php.net/manual/en/language.variables.php Edited July 7, 2006 by Klez Link to comment Share on other sites More sharing options...
janchuxss Posted July 7, 2006 Author Report Share Posted July 7, 2006 Tomēr man kautkas nesanāk. palasīju gan par switch gan par mainīgajiem un tomēr nekā. Uzrakstīju, kā Klez, bet neiet. <a href="?go=test">test</a> <?php switch ($_GET['go']) { case $abc: include ($abc . ".php"); break; default: echo ("lja ljaa"); break; } ?> Nestrādā, vislai ktikai defaulto rāda. Kur varētu būt problēma? Link to comment Share on other sites More sharing options...
KAC Posted July 7, 2006 Report Share Posted July 7, 2006 nu un kas tev tas par $abc ? Link to comment Share on other sites More sharing options...
janchuxss Posted July 7, 2006 Author Report Share Posted July 7, 2006 Vispār domāts mainīgais. Kā piemēram veido lyrics lapas? Vai tad tur kodā ir viss alfabēts, vai to tomēr kautkā savādāk veido? Es gribu lai links ?go=test man parāda test.php, tāpat, kā ?go=lapa parāda lapa.php utt ;) Link to comment Share on other sites More sharing options...
bubu Posted July 7, 2006 Report Share Posted July 7, 2006 Uzliec visos savos skriptos pirmo rindiņu šādu: error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
janchuxss Posted July 7, 2006 Author Report Share Posted July 7, 2006 Nū.. uzliku, bet nekādus errorus nemet.. Link to comment Share on other sites More sharing options...
litt Posted July 7, 2006 Report Share Posted July 7, 2006 include ($_GET['go'] . ".php"); P.S drošība šim risinājumam ir 0 Link to comment Share on other sites More sharing options...
janchuxss Posted July 7, 2006 Author Report Share Posted July 7, 2006 (edited) Liels paldies. Par drošību runājot, nav nepieciešams, tam, ko es veidoju :) Ēm, tomēr vēlviens Q, kā šamajam varētu piemest klāt defaulto includu? :) Edited July 7, 2006 by janchuxss Link to comment Share on other sites More sharing options...
litt Posted July 7, 2006 Report Share Posted July 7, 2006 if(!isset($_GET['go'])) inculde fails.php; Link to comment Share on other sites More sharing options...
janchuxss Posted July 7, 2006 Author Report Share Posted July 7, 2006 Vēlreiz liels paldies :) Tieši tas ko vēlējos ;) Topicu var slēgt :) Link to comment Share on other sites More sharing options...
Delfins Posted July 7, 2006 Report Share Posted July 7, 2006 Ēm, tomēr vēlviens Q, kā šamajam varētu piemest klāt defaulto includu? :) Nu moins... no tava paša koda default: echo ("lja ljaa"); break; Link to comment Share on other sites More sharing options...
Recommended Posts