Joel G Mathew
Joel G Mathew

Reputation: 8061

php script not executed from command line

I'm unable to execute php scripts from command line. I have the following simple code in a file named test.php:

#!/usr/bin/php
print password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";

On executing, I get this:

#./test.php
print password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";

About my environment, it's a Debian 7 x64 server.

#which -a php
/usr/bin/php    
#`which php` -v
PHP 5.6.9-0+deb8u1 (cli) (built: Jun  5 2015 11:03:27)

What could be wrong with my installation?

Upvotes: 0

Views: 732

Answers (1)

Elliot B.
Elliot B.

Reputation: 17651

You need to encapsulate your PHP code with the proper tags else it will be interpreted as plain text. Modify your PHP file to the following:

 <?php
      print password_hash("rasmuslerdorf",PASSWORD_DEFAULT)."\n";
 ?>

Upvotes: 2

Related Questions