In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use command-line commands in PHP. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
When the user opens the php page, the server executes the PHP command and sends the execution result to the user's browser, similar to the fact that ASP and CoildFusion,PHP can run on WINDOWS and multiple versions of UNIX. In addition to being able to manipulate your page, PHP can also send the title of HTTP.
You can set up cookie, manage digital signatures and redirect users, and it provides excellent connectivity to other databases (and ODBC), integrating a variety of external libraries to do anything to parse XML with PDF documents. Do you know what else you can do with the power of php? When running in a stand-alone cgi mode, you need a php executable program that has a lot of command-line parameters, some of which can be used for fun purposes. Here are all the php command-line parameters, where [] means optional and the table is a must.
Usage php [- Q] [- h] [- s] [- v] [- I] [- f] | {[args...]}-Q quiet mode. HTTP headers are not output.
-s convert php program files to HTML in color format (such as green for reserved words, blue for functions and variables, yellow for comments and red for strings, etc.).
-f reads and interprets the specified file.
-c read the php.ini file in
-an interactive operation
-d foo [= bar] defines that the value of the input item foo in ini is bar
-e outputs additional information for debugging and performance analysis
-z call into Zend extension file
-I related information about php
-h help itself.
1. Use the php-Q file name. php to use the php program as a shell program
two。 Use-s to turn your php program into html. Isn't that easy?
3. Using the odbc function of php, you can manipulate the database in the shell command.
Several commonly used commands
1. Check the version and configuration of php
Type php-v on the command line to see the current version of php.
PHP 5.2.17 (cli) (built: Feb 2 2011 11:19:21) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
Other options are:-m,-I. The author will not give Liezi here.
-m displays the valid modules currently loaded by php.
-I outputs phpinfo without html format.
Use the-ini option to output the number and path information of the current php loaded ini configuration files.
Php--ini-in-shell
2. Run the php program on the command line
Running php from the command line is very simple. But there are some precautions that you need to know. Server variables such as $_ SESSION cannot be used on the command line, and other code runs exactly as in the web server ^ _ ^.
Save the above code as hello.php. Type php-f hello.php at the command line. The display results are as follows:
Run the php command line echo
One of the benefits of executing php files from the command line is that some scheduled tasks can be executed through scripting. Without going through the web server ^ _ ^.
Of course, we can also debug the code directly in php: enter the php-r instruction and a ">" symbol appears. This means that you have entered the shell of php, and you can write code directly and execute it.
-bash-3.2$ php-r'> for ($itemo / echo "Number: {$I}\ n"; >} > 'Number: 0 Number: 1
You can also use the php-a command to turn on interactive mode, enter a line of code, and php will output the results in real time.
3. Detect php syntax and highlight output
Instead of executing the code, we can detect syntax errors in the php file at the command line.
-bash-3.2$ php-l hello.php
No syntax errors detected in hello.php
Programmers often need to highlight the php code as it is, using php-s
-bash-3.2$ php-s hello.php
4. Check the php manual
Starting with php5.1.2, programmers can view the manual under the php command line and type php-rf function. Will print out a brief introduction to the syntax of the function
-bash-3.2$ php-- rf strip_tags Function [function strip_tags] {- Parameters [2] {Parameter # 0 [$str] Parameter # 1 [$allowable_tags]}} this is the end of the article on "how to use command line commands in PHP". I hope the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good. Please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.