: This article mainly introduces the PHP Getting Started Guide-PHP manual notes. For more information about PHP tutorials, see. I used to learn PHP briefly and read PHP and MySQL Web development, as well as the help of a omnipotent search engine. For more information about the preparation system, refer to PHP Manual.
What can PHP do?
PHP is mainly used for script programs on the server side, but PHP functions are far from limited to this. PHP is mainly used in the following three fields:
Practical scripts
$_SERVER
It is a special PHP reserved variable, which contains all the information provided by the web server, called a super global variable. You can use$_SERVER['HTTP_USER_AGENT']
Check the browser used by visitors to browse the page.
For IE browsers,$_SERVER['HTTP_USER_AGENT']
The value may be:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like GeckoMozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
You can callstrpos()
Function to determine whether the user agent is an IE browser.
This code involvesstrpos()
,!==
AndFALSE
.
strpos()
Is a built-in function of PHP. its function is to search for another string (needle) in one string (haystack ). If yes, the function returns the position of needle in haystack relative to the beginning. If no, FALSE is returned.
For the above code,strpos()
The returned result is 7. Forstrpos()
The specific values returned may have different calculation methods in space and Chinese. we will discuss them later.
Process form
PHP is easy to process forms, and Super global variables can be used.$_POST
Obtain data. Use the following method to define a simple HTML form. when the user fills out the form and clicks the submit button, the pageaction.php
Will be called.
Name:Age:
The following code prints data from the form.
Hello, . You are year(s) old.
This code also involveshtmlspecialchars()
And(int)
.htmlspecialchars()
So that special characters in HTML are correctly encoded, so that HTML tags or Javascript code are not injected into the page by the user.
Tools
To do well, you must first sharpen your tools.
There is a good tool to get twice the result with half the effort. To improve efficiency, I like to use VIM and run code in the command line.
This post is good about tools. what is the cmd replacement tool in window? -Windows-SegmentFault.
WampServer and XAMPP are recommended in the PHP environment.
(Full text)
The above is the PHP Getting Started Guide-PHP manual notes. For more information, see PHP Chinese website (www.php1.cn )!