Eight tips commonly used in PHP website development. Eight tips commonly used in PHP website development this article mainly introduces eight tips commonly used in PHP website development, this article explains the following eight tips: Naming, using, determining whether to submit a Form using PHP, and obtaining common PHP website development skills.
This article mainly introduces eight tips commonly used in PHP website development, this article describes how to name, use, determine whether to submit a Form using PHP, obtain the string length using PHP, and obtain a PHP ultra-global object. For more information, see
PHP is a server scripting language used to create dynamic web pages. Like ASP and ColdFusion, users can use PHP and HTML to write WEB pages. when the visitor browses the page, the server first processes the PHP commands on the page, then, the processed results and HTML content are sent to the browser at the access end. However, unlike ASP or ColdFusion, PHP is an open source code program with good cross-platform compatibility. You can run PHP on Windows NT and many versions of Unix systems, and run PHP as a built-in module of the Apache server or CGI program. This article summarizes eight tips commonly used in daily PHP development.
PHP batch obtains the maximum checkbox value
1. name
The code is as follows:
$ Expr = join (",", $ _ POST ['checkbox']);
$ SQL = "select * from tbl_name where field in ($ expr )";
}
If the field involved in the control is numeric
The code is as follows:
If (! Empty ($ _ POST ['checkbox']) {
$ Expr = "'". join ("', '", $ _ POST ['checkbox']). ".";
$ SQL = "select * from tbl_name where field in ($ expr )";
}
3. PHP checks whether the Form is submitted.
The code is as follows:
$ Action = $ HTTP_POST_VARS ["Button1"];
If ($ action = "submit ")
{
// Execute the form operation
}
Else
{
// Read the default value
}
4. PHP obtains the string length.
The code is as follows:
Strlen ($ myrow [1])
PHP Url redirection
The code is as follows:
Header ("Location:". $ _ SERVER ["HTTP_REFERER"]);
5. PHP Super global object
The code is as follows:
$ A = 1;
$ B = 2;
Function Sum ()
{
$ GLOBALS ["B"] = $ GLOBALS ["a"] + $ GLOBALS ["B"];
}
Sum ();
Echo $ B;
?>
6. PHP form values
If mothod = "get", replace $ _ GET ["test"] with $ test.
If mothod = "post", replace $ _ POST ["test"] with $ test.
7. PHP obtains the current IP address
The code is as follows:
8. PHP obtains the current time
The code is as follows:
Echo date ("Y-m-d G: I: s ");
?>
Date ("Y-m-D ")
Date ("Y-n-j ")
This article mainly introduces eight tips commonly used in PHP website development. This article describes naming, using, PHP determining whether to submit a Form, PHP obtaining...