Using echo with PHP CLI?

The following script is executed in the PHP CLI:

<?php echo 'hello world!'; ?> 

I can not see anything. How to enable output?

+4
source share
3 answers

Run it in the terminal:

 php -r 'echo "Hello World!\n";' 
+17
source

Looks like you forgot the shebang line. Yours may vary depending on your setup, but you need to point to php somehow.

  #!/usr/bin/env php <?php echo 'hello world!'; ?> 
+2
source

Verify that the user has permission to run the file.

+1
source

Source: https://habr.com/ru/post/1390169/


All Articles