PHP parse error after upgrade

PHP parse error after upgrade

am 20.12.2007 19:50:58 von Jim McCullars

Greetings!

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 ?> }elseif ($navtable == 'student'){
echo ?> }elseif ($navtable == 'staff'){
echo ?> }elseif ($navtable == 'visit'){
echo ?> }elseif ($navtable == 'apply'){
echo ?> }elseif ($navtable == 'links'){
echo ?> }elseif ($navtable == 'recruit'){
echo ?>
}elseif ($navtable == 'international'){
echo ?> }else{
echo 'Please call 827-6414 to report a problem on this page';
}
?>

Line 48 is the one that says
echo ?>
This script does not generate any errors under 4.4.4. I did look at the
4 to 5 compatibility guide on the php.net site but I didn't see anything
that would explain this. Can someone give me a hint as to why this no longer
work under version 5? Thanks!

Jim McCullars
University of Alabama in Huntsville

Re: PHP parse error after upgrade

am 20.12.2007 20:12:12 von ivansanchez-alg

Jim McCullars wrote:

> echo ?>

*ahem*. What are you echo()ing, again?

> This script does not generate any errors under 4.4.4. I did look at
> the 4 to 5 compatibility guide on the php.net site but I didn't see
> anything that would explain this. Can someone give me a hint as to why
> this no longer work under version 5? Thanks!

I'm guessing that in PHP4 a "?>" implied a ";". It still does, but if the
start and end tags are in the same line, and there is just one sentence in
between.

Just a guess - grab a copy of the parser's source code and its grammar if
you really want to be sure. In the meantime, please fix your empty
echo()es.


Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

You never know how many friends you have until you rent a house on the
beach.

Re: PHP parse error after upgrade

am 20.12.2007 20:20:52 von Michael Fesser

..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 ?> > }elseif ($navtable == 'student'){
> echo ?> > }elseif ($navtable == 'staff'){
> echo ?> > }elseif ($navtable == 'visit'){
> echo ?> > }elseif ($navtable == 'apply'){
> echo ?> > }elseif ($navtable == 'links'){
> echo ?> > }elseif ($navtable == 'recruit'){
> echo ?> >
> }elseif ($navtable == 'international'){
> echo ?> > }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:

$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

Re: PHP parse error after upgrade

am 20.12.2007 20:20:56 von unknown

Post removed (X-No-Archive: yes)