What is PHP? PHP ("PHP: HypertextPreprocessor", short for Hypertext Preprocessor) is a widely used open-source multi-purpose scripting language that can be embedded into HTML, especially suitable for WEB development. The above is a simple
What is PHP?
PHP ("PHP: Hypertext Preprocessor", short for Hypertext Preprocessor) is a widely used open-source multi-purpose scripting language that can be embedded into HTML, especially suitable for WEB development.
The above is a simple answer, but what does this mean? See the following example:
Example 1-1. a model of compatibility
Example
Echo 'Hi, I'm a PHP script! ';
?>
Pay attention to the difference between this model and other scripts written in C or Perl-unlike writing a program with a large number of commands to output HTML, we have written an HTML script in PHP, where some code is embedded to do some things (for example, some text is output in this example ). The PHP code is contained by a special start and end characters, allowing you to enter and exit the "PHP mode ".
Unlike the client's JavaScript code, the PHP code runs in the service. If you have created code similar to the above example on your server, the client will receive the result after running the script, but they cannot know how the code behind it works. You can even set the WEB server to PHP to process all HTML files, so that users cannot know what the server has done.
One of the major benefits of using PHP is its simplicity for beginners. It also provides various advanced features for professional programmers. Do not be afraid when you see the PHP long feature list. You can enter the door quickly and write some simple scripts by yourself in just a few hours.
Although PHP is developed with a server script as the target, its function is far from limited.
What can PHP do?
PHP can do anything. PHP is mainly used to serve a real script program. Therefore, you can use PHP to complete the work that can be done by any other CGI program, such as collecting form data and daily lively Web pages, or send/receive Cookies. However, PHP functions are far from limited to this.
PHP scripts are mainly used in the following three categories.
Server script. This is the most traditional and important target scope of PHP. To do this, you must have the following three items: PHP parser (CGI or server module), WEB server, and WEB browser. You need to install and configure PHP when running the WEB server. then, you can use a WEB browser to visit the output of the PHP program, that is, browse the PHP page of the service. For more information, see the "install" chapter.
Command line script. You can write a PHP script without running it on any server or browser. In this way, you only need the PHP parser. This usage is a fantasy choice for scripts that are attached to cron (Unix or Linux environment) or Task Scheduler (Windows environment) for daily running. These scripts can also be used to process simple text. For more information, see "PHP command line mode.