redirect - Default Content on failed require_once -


just started learning php today. , though moved through of problems quickly, got stumped one.

i have main page page.php dynamic require_once pull content. got main part working, page.php?id=1 page.php?id=2 etc load fine, if goes page.php without id, there errors ruin page. figured out how repress errors @ , can set links page page?if=default, need solution having page.php load content specific without errors. or, perhaps, automatically redirect page.php page.php?id=default should no id provided.

the code current using require_once is:

<?php require_once('folder/' .  $_get['id'] . '.html');?> 

thank help!

well easiest way check if have id , if not, set default one, that:

$default = 1; $id = ($_get['id'] && is_numeric($_get['id'])) ? $_get['id'] : $default; require_once('folder/' .  $id . '.html'); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -