PHP Getting Started Guide-PHP manual notes

Source: Internet
Author: User
: 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:

  • Server script

  • Command line script

  • Write desktop applications (PHP-GTK)

Practical scripts

$_SERVERIt 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.$_POSTObtain 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.phpWill 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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.