Atomz Posted March 8, 2007 Report Share Posted March 8, 2007 Kā lai uztaisa tādu prikolu, ka man ir, piemēram, <?php include("kautkas"); ?> un nospiežot linku pamaina no <?php include("kautkas"); ?> uz <?php include("nezinu_kas"); ?> Lūdzu palīdziet! Link to comment Share on other sites More sharing options...
andrisp Posted March 8, 2007 Report Share Posted March 8, 2007 (edited) <a href="?x=kautkas">kautkas</a> <a href="?x=nezinu_kas">nezinu_kas</a> <?php include($_GET['x']); ?> Tikai silti iesaku validēt to $_GET['x'] pirms izmantošanas. Es darītu šādi: $valid_includes = array( 'kautkas' => 'kautkas.php', 'nezinu_kas' => 'nezinu_kas.php' ) if (!empty($_GET['x']) && isset($valid_includes[$_GET['x']])) { include($valid_includes[$_GET['x']]); } Kaut kā tā. Edited March 8, 2007 by andrisp Link to comment Share on other sites More sharing options...
Atomz Posted March 8, 2007 Author Report Share Posted March 8, 2007 Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.;C:\php5\pear') in C:\AppServ\www\Tests\index.php on line 14 a 14 līnijā man ir šitas: <?php include($_GET['x']); ?> tipa pēc manām domām vajadzētu kautko līdzīgu kā default priekš tā x noteikt, bet KĀ? :) Link to comment Share on other sites More sharing options...
andrisp Posted March 8, 2007 Report Share Posted March 8, 2007 Nu protams: if (empty($_GET['x'])) { $_GET['x'] = 'defaultaa_lapa'; } Link to comment Share on other sites More sharing options...
Val Posted March 8, 2007 Report Share Posted March 8, 2007 kautvai ar switch case 'kautkas' case 'hujuvinjzinkas' case default un nebūs arī jāpārbauda, ko satur $_GET['x'] Link to comment Share on other sites More sharing options...
Atomz Posted March 8, 2007 Author Report Share Posted March 8, 2007 A es iesācējs PHP esu! varat pateikt kā lai savieno <?php include($_GET['x']); ?> ar if (empty($_GET['x'])) { $_GET['x'] = 'defaultaa_lapa'; } Link to comment Share on other sites More sharing options...
Val Posted March 8, 2007 Report Share Posted March 8, 2007 šitam galā varētu pielikt: $valid_includes = array( 'kautkas' => 'kautkas.php', 'nezinu_kas' => 'nezinu_kas.php' ) if (!empty($_GET['x']) && isset($valid_includes[$_GET['x']])) { include($valid_includes[$_GET['x']]); } else { $_GET['x'] = 'defaultaa_lapa'; //include bla bla bla } Link to comment Share on other sites More sharing options...
Recommended Posts