Home > Backend Development > PHP Tutorial > php cli php in command line

php cli php in command line

WBOY
Release: 2016-07-30 13:30:03
Original
846 people have browsed it

Resource: http://php-cli.com/php-cli-tutorial.shtml

Write a php file

<code><span>sudo</span> vim /var/www/html/a.php</code>
Copy after login

Write interpreter at the beginning of the file

<code>#!/usr/bin/php
<span><span><?php</span><span>include</span>(<span>'...'</span>); <span>/*we can include orther *.php */</span><span>echo</span> `ls -al`; <span>/* exe the linux command with `` */</span><span>?></span></span></code>
Copy after login

Change the permissions and run directly

<code>-<span>>sudo chmod <span>777</span> /var/www/html/a.php  
</span>-<span>>./a.php   </span></code>
Copy after login

tips

Some functions and statements are specially designed for PHP-CLI scripts
Waiting for command line input: $name = fgets(STDIN); //The program is paused here, waiting for input
echo getcwd() .”/n”; //Get the current script path

Copyright statement: Knowledge comes from the people, and is used by the people! Reprinting is welcome. Please attach a link to this article at the beginning. The article will be updated from time to time!

The above introduces php in the php cli command line, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template