Home >Backend Development >PHP Problem >How to execute code from php command line

How to execute code from php command line

王林
王林Original
2019-10-17 15:07:148436browse

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';"

How to execute code from php command line

2. Create a new PHP document, example:

<?php
// 输出一段简单的话
echo &#39;welcome baidu&#39;;

How to execute code from php command line

3. Use php -f to execute the file, php -f followed by the relative path of the file, or the absolute path

How to execute code from php command line

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn