I once briefly learned PHP by reading "PHP and MySQL Web Development" and with the help of a universal search engine. This time I am going to study the system. The reference material is PHP Manual.
What PHP can do
PHP is mainly used for server-side script programs, but the functions of PHP are far from limited to this. PHP is mainly used in the following three areas:
Server scripts
Command line scripts
Writing desktop applications (PHP-GTK)
Practical scripts
$_SERVER
is a special PHP reserved variable that contains all the information provided by the web server and is called a superglobal variable. You can use $_SERVER['HTTP_USER_AGENT']
to check what browser the visitors to the page are using.
For IE browser, the value of $_SERVER['HTTP_USER_AGENT']
may be:
Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko Mozilla/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 determine whether the user agent is IE browser by calling the strpos()
function.
<?php $ua = $_SERVER['HTTP_USER_AGENT']; if(strpos($ua, 'Trident') !== FALSE || strpos($ua, 'MSIE') !== FALSE) { echo 'You are using Internet Explorer.'; } else { echo 'You are not using Internet Explorer.'; }
This code involves the use of strpos()
, !==
and FALSE
.
strpos()
is a built-in function of PHP. Its function is to search for another string (needle) in a string (haystack). If found, the function returns the position of the needle relative to the beginning in the haystack; if not, it returns FALSE.
<?php $haystack = 'hello, world.'; $needle = 'wo'; echo strpos($haystack, $needle);
For the above code, the result returned by strpos()
is 7. For the specific value returned by strpos()
, the calculation method may be different for spaces and Chinese, which will be discussed later.
Processing forms
PHP’s way of processing forms is very convenient. You can use the super global variable $_POST
to 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 page action.php
will be called.
Name:Age:
The following code can print data from the form.
Hello, . You are year(s) old.
This code also involves the use of htmlspecialchars()
and (int)
. htmlspecialchars()
enables special characters in HTML to be correctly encoded, so that users will not inject HTML tags or Javascript codes into the page.
Tools
If a worker wants to do his job well, he must first sharpen his tools.
With a good tool, you can get twice the result with half the effort. For efficiency, I like to use VIM and run code from the command line.
As for tools, this post talks about it well. Is there an alternative tool for cmd under window? - windows - SegmentFault.
WampServer and XAMPP are recommended for PHP environment.
(Full text ends)
The above is the content of PHP Getting Started Guide - PHP Manual Notes. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools