Reply to Re: PHP parse error after upgrade

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация