Programming This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
05-13-2014, 11:23 AM
|
#1
|
Member
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 22.04
Posts: 473
Rep:
|
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.
I am at a standstill. Please help.
Code:
<?php
print "hello rick";
?>
|
|
|
05-13-2014, 11:29 AM
|
#2
|
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278
|
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.
|
|
|
05-13-2014, 11:44 AM
|
#3
|
Member
Registered: Jun 2005
Location: Hayden, ID
Distribution: Ubuntu 22.04
Posts: 473
Original Poster
Rep:
|
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!!
|
|
|
05-13-2014, 12:15 PM
|
#4
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,037
|
Well if no Windows in the way, may we ask how you are running / viewing / parsing this and where you are getting the error?
|
|
|
05-13-2014, 12:26 PM
|
#5
|
LQ Guru
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 5,073
|
> syntax error, unexpected end of file in Command line code on line 1
Please quote the exact command you used.
|
|
|
12-11-2014, 09:31 AM
|
#6
|
LQ Newbie
Registered: Jan 2007
Posts: 19
Rep:
|
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!
|
|
|
12-11-2014, 12:09 PM
|
#7
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
Your problem was not where the option was placed (php -r myscript.php), it was that that the "-r" option is unnecessary for executing a file.
The "-r" option is for executing code directly. See the man page examples: link
|
|
|
12-11-2014, 12:26 PM
|
#8
|
LQ Guru
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 5,073
|
No, this '-r' was not meant for '/usr/bin/php', it was meant for 'myscript.php'.
|
|
|
12-11-2014, 12:49 PM
|
#9
|
Member
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792
|
Whoops. Exposed my lack of reading comprehension.
|
|
|
All times are GMT -5. The time now is 09:13 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|