Alex
Alex

Reputation: 34978

Parsing differences / error in PHP7.0.3 <?php$foo

I have the following code:

<?php$selectbox->display();?>

which is not too much nice, but runs well on Ubuntu PHP 7.0.3-1+deb.sury.org~vivid+1 (mod_php)

On my uberspace with PHP 7.0.3 (FCGI) I get the error

mod_fcgid: stderr: PHP Parse error:  syntax error, 
   unexpected '$selectbox' (T_VARIABLE) 

Why could this be?

Just asking out of curiosity - the fix itself is simple of course.

Upvotes: 5

Views: 185

Answers (1)

B. Desai
B. Desai

Reputation: 16436

The issue is not due to different system. It depends on php configuration in php.ini file. In this case it depends on the short_open tag.

Maybe short_open is set to On in php.ini at uberspace, so after <? it will be considered as php starts and take the php(after <?) as constant. Therefore it will throw error for $selectbox. You can try with following debugging for confirm that its an actual problem of short_open.

1) Set short_open to Off. In php.ini change following line

short_open_tag = On

to

short_open_tag = Off

2) Or, Remove php after <? If you don't want to change php configuration

<?$selectbox->display();?>

Upvotes: 3

Related Questions