Jump to content
Larry Ullman's Book Forums

Chapter 11 - Cli


Recommended Posts

Hi,

 

I'm taking an online course that uses your book. My system runs Win 7 with the xampp setup, and actually works very nicely - 'til now.

 

Trying the initial test (php -v) results in a nasty ''php' is not recognized as an internal or external command,

operable program or batch file.' Missing info in the path statement, I suspect. Tried entering C:\xampp\php\ there, but still got the same result. In \xampp\php\ there is a file 'php-cgi.exe' (nothing that refers to 'cli'). Does this need to be added to the path statement? Also, does the system need a restart for the new path to be recognized?

 

Needless to say, I'm a Mac guy, but my 9 year old PPC does not support CS5, and also has a very old version of PHP loaded, so I'm pushed to my Win machine. Apologies for my 'Page 1' questions.

 

Thoughts appreciated.

 

John

Link to comment
Share on other sites

Hey, John. I can't answer all your questions, but some of them.

 

- Yes. If you edit the configuration, you need to restart Apache.

- Xampp is very easy to get up and running. (both on Mac and PC - I use both) How about taking a backup of your content, then reinstall xampp?

 

- Are you using an URL like http://localhost to watch your content? (Standard for Xampp)

- Are your web content inside the folder "htdocs" found in xampp?

 

Sorry if these questions are moronic/a personal insult/etc. Trivial stuff's easy to overlook.

  • Upvote 1
Link to comment
Share on other sites

Hi Antonio,

 

Hey, John. I can't answer all your questions, but some of them.

 

- Yes. If you edit the configuration, you need to restart Apache.

 

Hmm - I was under the impression the the CLI didn't use Apache, but rather a special version of PHP.

 

- Xampp is very easy to get up and running. (both on Mac and PC - I use both) How about taking a backup of your content, then reinstall xampp?

Xampp has actually been installed twice - the initial, and then an update. It's running just fine.

 

- Are you using an URL like http://localhost to watch your content? (Standard for Xampp)

 

Yes.

 

 

- Are your web content inside the folder "htdocs" found in xampp?

 

Yes. It's a standard install.

 

 

Sorry if these questions are moronic/a personal insult/etc. Trivial stuff's easy to overlook.

 

No problems with your questions here. But I am confused by them, as at this point I haven't even started trying to run a script yet - just trying to get a version from the PHP CLI. Also, I see nothing in the book about configuring Apache, but just a mention that the CLI uses a different php.ini than Apache does.

 

Thanks.

 

John

Link to comment
Share on other sites

Hello John. For me, using XAMPP on Windows 7, C:\xampp\php\php -v works.

HI Larry,

 

Thanks for the reply.

 

Finally got it going with C:\xampp\php in the path...

 

C:\xampp\php>php -v

PHP 5.3.1 (cli) (built: Nov 20 2009 17:26:32)

Copyright © 1997-2009 The PHP Group

Zend Engine v2.3.0, Copyright © 1998-2009 Zend Technologies

 

Discovered I don't have to cd in the cmd line and php -v works now.

 

H o w e v e r - The following fails...

 

C:\Users\John>php -r 'echo "Hello, World!";'

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in Command line

code on line 1

 

I think you'll recognize that as straight out of the book. To make this short, the final fix was to reverse all the quotes (' for ", " for ')...

 

C:\Users\John>php -r "print('Hello, World!');"

Hello, World!

 

This is as far as I've gotten, so I don't know what the status of the other scripts in this chapter is.

 

Makes no sense to me. Hopefully you'll know why.

 

Thanks again.

 

 

John

Link to comment
Share on other sites

I can test separate on my Windows computer if you want, but on my Mac,

php -r 'echo "Hello, world!";'

works just fine. However,

php -r "echo 'Hello, world!';"

does not.

 

So I expect this is an operating-system difference thing.

Link to comment
Share on other sites

I can test separate on my Windows computer if you want, but on my Mac,

php -r 'echo "Hello, world!";'

works just fine. However,

php -r "echo 'Hello, world!';"

does not.

 

So I expect this is an operating-system difference thing.

Believe me, I wish I were on my Mac. Unfortunately, it's just an old PPC machine, with most everything no longer supported. So, the box I'm using is running Win 7 Pro.

 

Interesting to note, I entered the temp conversion script and ran it from the command line without changing any of the quotes. It ran fine! Been in computers as a profession since '65 - mainframe IBMs to Macs. This fits the pattern! :rolleyes:

 

Thanks.

 

John

Link to comment
Share on other sites

Thanks for letting me know. I don't say this too often, especially not in books, but I kind of hate computers! So very...inexplicable...sometimes. As a person dedicated to explaining the why's of technical things, I can't get away with "Magic Gnomes" answers as much as I'd like to!

Link to comment
Share on other sites

 Share

×
×
  • Create New...