Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

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.

like image 946
Alex Avatar asked Oct 18 '22 14:10

Alex


1 Answers

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();?>
like image 80
B. Desai Avatar answered Oct 21 '22 06:10

B. Desai