PHP Parse error: syntax error, unexpected end of file in Command line code on line 1
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
PHP Parse error: syntax error, unexpected end of file in Command line code on line 1
This seems ridiculous.
I was in the middle of working out some bugs in another PHP program when I started getting the subject error. I started commenting out portions of the program until I had commentd out everything. Nothing fixed it so I created the code below with the same results.
Do you mean you created a new file, or are you using the old one?
I would be wary of editing in windows and saving on linux via ftp/scp or whatever. What editor are you using? Have you looked at the contents of the file with vim and turned on view all characters?
In other words, it sounds like an invisible character mucking it up.
I use Ubuntu 13.04. With Firefox and Bluefish, although I created the sample program with gedit. I don't know a thing about Vim though. No Windows on machine.
Just to be sure about hidden characters I made a new same program. Same results!!
As this is the top Google result for "unexpected end of file in Command line code", I'll post what fixed this problem for me. It turns out I had placed the option I wanted to pass to my script between "php" and the script filename. Like this
Code:
php -r myscript.php
instead of
Code:
php myscript.php -r
As you work with the command line a lot, you get so used to adding a new option directly after the command name that this is a mistake easily made . Just remove the option between "php" and the script name and re-add it after the script name and you're done!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.