Home > Mobile >  Ubuntu 20 terminal PHP script output
Ubuntu 20 terminal PHP script output

Time:12-17

Ubuntu 20 running on WSL, PHP 7.4

I am trying to debug code but cannot seem to get any output from the script. To replicate:

myfile.php

<?php
echo "output text";

called from the terminal with

php myfile.php

The script runs but returns nothing.

CodePudding user response:

You are trying to do int in right way. You can tell php to execute a file like the following:

php myfile.php

... or

php -f myfile.php

You can check the following two things.

  1. First one is that make sure you have installed php cli.
  2. In your script try to put that line #!/usr/bin/php on very top of the file. So your file will looks like the following:
#!/usr/bin/php
<?php
echo "output text";

Hope that helps you or at least gives you a right direction.

CodePudding user response:

For Debug your system needs some tools.

Run: php -v and see your php version.

You need to make sure you have module php installed.

Install: phpx.x-cli

  • Related