0

I am using xampp and windows OS. I am trying to execute simple php script command line but I got an error like "Could not open input file http://test.localhost.com/test.php". Below is my code for the same.

#!/usr/local/bin/php  
<?php  
$stdin = fopen('php://stdin', 'r');  
while (true) {  
        $input = fgets($stdin, 3);  
        if ($input == 42) {  
                break;  
        } else {  
                echo $input;  
        }  
}  
fclose($stdin);  
exit;

I giving me above error. Can anyone tell me what is the problem?

4
  • How are you executing this script? Commented Jul 11, 2012 at 13:25
  • 1
    Why would you be using a UNIX hashbang and UNIX path to PHP if you're on Windows? Commented Jul 11, 2012 at 13:26
  • 1
    Your post contradicts itself. Are you running from the command line or in your browser? If you are running it from the command line, then specify the file name, not a URL. Commented Jul 11, 2012 at 13:26
  • It seems you want to run a CLI php in browser. Do you? Commented Jul 11, 2012 at 13:28

1 Answer 1

1

You want to call a CLI script, not a website.

c:/path/to/php.exe c:/path/to/scrip.php
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.