Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

in Windows 7 I launch PHP.exe but then there's just a pure black command prompt screen and nothing I type results in any feedback at all. If I type:

PHP -I

Nothing. If I type

PHPinfo()

Nothing.

Nothing beyond a blinking underscore cursor. Everything else in the command window is black. (Ctrl C brings me back to to a dir command prompt.)

share|improve this question
    
No errors, no output, no nothing? –  Coding Gorilla Oct 7 '11 at 15:26
    
It's been so long since I've used this. I went back after I posted and tried entering the statements directly into the command line and everything's fine. I had been typing "php" and pressing return and then been trying to use the statements. (As I said it's been a long time.) Everything's cool now. Thanks for replying. –  M M Oct 7 '11 at 15:36

1 Answer 1

PHP was initially a HTML preprocessor, and the interprreter only executes code inside <?php ?> tags; the rest is left untouched. The way you are using it now, php would just print the text phpinfo() back to you.

But it doesn't do so because it is waiting for the rest of the page to be input, and will delay execution until it reaches "end of file". On Windows this means you have to enter Ctrl-Z on a line by itself.

That, and your input is missing the "end of statement" marker – the ;.

<?php

phpinfo();

Ctrl-Z Enter

If you want to use "interactive" mode as in Python or Ruby's irb, you need to run php -a, which will execute every line immediately.

You will still need <?php, however, and it will still immediately die on syntax errors, so (these were fixed in 5.4)

I suggest you to use a text editor instead – write some code, save it to test.php, then run php test.php from command line. Edit, fix bugs, run php test.php again.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.