|
Posted by Michael Fesser on 12/20/07 19:20
..oO(Jim McCullars)
> While doing a web server upgrade, I also decided to upgrade PHP from
>4.4.4 to 5.2.5. After putting the new server in a test environment (actually
>just listening on a different port and using the same DocumentRoot), one
>PHP script fails with a message like this:
>
>PHP Parse error: syntax error, unexpected ';' in
>/apps/httpd/data/admissions/pagemaker.php on line 48
>
>Here is a snippet of the script that failed:
>
> <?
> if ($navtable == 'about'){
> echo ?> <? include("./aboutnavtable.inc"); ?> <?
> }elseif ($navtable == 'student'){
> echo ?> <? include("./studentnavtable.inc"); ?> <?
> }elseif ($navtable == 'staff'){
> echo ?> <? include("./staffnavtable.inc"); ?> <?
> }elseif ($navtable == 'visit'){
> echo ?> <? include("./visitnavtable.inc"); ?> <?
> }elseif ($navtable == 'apply'){
> echo ?> <? include("./applynavtable.inc"); ?> <?
> }elseif ($navtable == 'links'){
> echo ?> <? include("./linksnavtable.inc"); ?> <?
> }elseif ($navtable == 'recruit'){
> echo ?> <? include("./recruitnavtable.inc"); ?> <?
>
> }elseif ($navtable == 'international'){
> echo ?> <? include("./internationalnavtable.inc"); ?> <?
> }else{
> echo 'Please call 827-6414 to report a problem on this page';
> }
> ?>
Uh ... ugly, buggy and unreliable. What about replacing this mess with
something like this:
<?php
$pages = array('about', 'student', 'staff', ...);
if (in_array($navtable, $pages)) {
include "{$navtable}navtable.inc";
} else {
echo 'Please call 827-6414 to report a problem on this page';
}
?>
Micha
Navigation:
[Reply to this message]
|