Home >Backend Development >PHP Problem >How to execute code from php command line
1. Use the php -r command to directly execute the code, example:
php -r "echo 'hello world';"
2. Create a new PHP document, example:
<?php // 输出一段简单的话 echo 'welcome baidu';
3. Use php -f to execute the file, php -f followed by the relative path of the file, or the absolute path
Recommended tutorial: PHP video tutorial
The above is the detailed content of How to execute code from php command line. For more information, please follow other related articles on the PHP Chinese website!