LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Getting PHP Parse error on Virtual Server (https://www.linuxquestions.org/questions/programming-9/getting-php-parse-error-on-virtual-server-4175659663/)

Mental-Octopus 08-23-2019 08:13 AM

Getting PHP Parse error on Virtual Server
 
So I set up a virtual server on Ubuntu.
I uploaded a webpage in PHP which had no errors on the another Ubuntu server and on my local computer but for some reason shows a parse error on the Ubuntu Virtual server. So I'm wondering what the possibilities are for causing this error because I know for a fact the webpage has no errors unless different Ubuntu versions have different set of rules. Because the other OS I tested the webpage on is a slightly different linux distribution but same PHP version that is PHP7.

TB0ne 08-23-2019 08:45 AM

Quote:

Originally Posted by Mental-Octopus (Post 6028590)
So I set up a virtual server on Ubuntu.
I uploaded a webpage in PHP which had no errors on the another Ubuntu server and on my local computer but for some reason shows a parse error on the Ubuntu Virtual server. So I'm wondering what the possibilities are for causing this error because I know for a fact the webpage has no errors unless different Ubuntu versions have different set of rules. Because the other OS I tested the webpage on is a slightly different linux distribution but same PHP version that is PHP7.

Since you don't say what version of Ubuntu, or tell us anything about your script, or even the actual error, who knows?? Have you done any troubleshooting? Looked at the Apache and PHP log files? Checked the Apache versions?

Post your script along with the actual errors and some details, and we can try to help. But based on what you posted, there's nothing we can tell you.

michaelk 08-23-2019 09:55 AM

There are many possibilities and all we basically know is there is something different between the two environments.

Something is not installed, installed incorrectly or configured incorrectly.
PHP is not configured correctly.
Apache or whatever web server is running is not configured correctly.

You will need to go back and reexamine the error and your script and hopefully it will become obvious why it isn't working as expected.

Mental-Octopus 08-23-2019 09:58 AM

Quote:

Originally Posted by michaelk (Post 6028614)
There are many possibilities and all we basically know is there is something different between the two environments.

Something is not installed, installed incorrectly or configured incorrectly.
PHP is not configured correctly.
Apache or whatever web server is running is not configured correctly.

You will need to go back and reexamine the error and your script and hopefully it will become obvious why it isn't working as expected.

Thanks a lot I will check now as to the version I'm using and php installation, I thought it could be something like that
just wanted to confirm.
PHP Parse Error: syntax error unexpected '}', expecting end of file in /var/www/file.php

I'm using the latest version of ubuntu which is 19.

TB0ne 08-23-2019 10:24 AM

Quote:

Originally Posted by Mental-Octopus (Post 6028618)
Thanks a lot I will check now as to the version I'm using and php installation, I thought it could be something like that
just wanted to confirm.
PHP Parse Error: syntax error unexpected '}', expecting end of file in /var/www/file.php

I'm using the latest version of ubuntu which is 19.

Well, seems simple enough; you have a typo in your code. How did you put this 'file.php' onto your new server??

NevemTeve 08-23-2019 11:20 AM

Sometimes it is <? instead of <?php
Edit:
<? often works; <?php always works

Mental-Octopus 08-23-2019 12:15 PM

Quote:

Originally Posted by TB0ne (Post 6028627)
Well, seems simple enough; you have a typo in your code. How did you put this 'file.php' onto your new server??

Uploaded by sftp.

Mental-Octopus 08-23-2019 12:28 PM

Quote:

Originally Posted by NevemTeve (Post 6028652)
Sometimes it is <? instead of <?php

Really? I heard that it was the opposite.

TB0ne 08-23-2019 12:31 PM

Quote:

Originally Posted by Mental-Octopus (Post 6028676)
Really? I heard that it was the opposite.

Depends on version of PHP.

NevemTeve 08-23-2019 12:33 PM

To be clear: <? often works (depends on a php.ini setting); <?php always works

Mental-Octopus 08-23-2019 12:36 PM

Finally found the error now folks, thanks a lot yeah.
It was this demon here <? that I had to change to this <?php
Though I don't understand why some linux version treat the matter differently.

ondoho 08-23-2019 01:05 PM

Quote:

Originally Posted by Mental-Octopus (Post 6028686)
I don't understand why some linux version treat the matter differently.

Not Linux versions; PHP versions.
And the answer to that is in the previous post.

michaelk 08-23-2019 01:48 PM

It depends on distribution / version if the short open tag <? is enabled or disabled by default. Although I had read that with version 7.0 it was deprecated although from the posted PHP page it has not.


All times are GMT -5. The time now is 11:40 AM.