PHP Web site development commonly used in 8 tips
This article mainly introduces the PHP Web site development commonly used in 8 tips, this article explains the name, use, PHP to determine whether form forms submitted, PHP get string length, PHP super-global objects and other content, the need for friends can refer to the next
PHP is a server-side scripting language for creating dynamic Web pages. Like ASP and ColdFusion, users can mix PHP and HTML to write Web pages, and when a visitor browses to the page, the server first processes the PHP commands in the page and then sends the processed results along with the HTML content to the browser on the access side. However, unlike ASP or ColdFusion, PHP is a source code open program with good cross-platform compatibility. Users can run PHP on the Windows NT system and on many versions of UNIX systems, and can run PHP as a built-in module or CGI program for the Apache server. This article summarizes the 8 tips commonly used in daily development of PHP.
The PHP batch gets the value of the checkbox
1. Naming
The code is as follows:
$expr = Join (",", $_post[' checkbox ');
$sql = "SELECT * from Tbl_name where field in ($expr)";
}
If the field that participates in the control is numeric, the
The code is as follows:
if (! empty ($_post[' checkbox '))) {
$expr = "'". Join ("', '", $_post[' checkbox ']). ".";
$sql = "SELECT * from Tbl_name where field in ($expr)";
}
3, PHP to determine whether form forms submitted
The code is as follows:
$action = $HTTP _post_vars["Button1"];
if ($action = = "Submit")
{
Perform form actions
}
Else
{
Read default values
}
4. PHP gets the string length
The code is as follows:
Strlen ($myrow [1])
PHP URL Steering
The code is as follows:
Header ("Location:". $_server["Http_referer"]);
5. PHP Hyper-Global objects
The code is as follows:
$a = 1;
$b = 2;
function Sum ()
{
$GLOBALS ["b"] = $GLOBALS ["a"] + $GLOBALS ["B"];
}
Sum ();
Echo $b;
?>
6, PHP form to take value
If mothod= "get" uses $_get["test" instead of $test
If mothod= "POST" uses $_post["test" instead of $test
7. PHP obtains the current IP
The code is as follows:
8. PHP Gets the current time
The code is as follows:
echo Date ("y-m-d g:i:s");
?>
Date ("Y year M month D Day")
Date ("Y-n-j")
http://www.bkjia.com/PHPjc/958132.html www.bkjia.com true http://www.bkjia.com/PHPjc/958132.html techarticle PHP Web site development commonly used in 8 tips This article mainly introduces the PHP Web site development commonly used in 8 tips, this article explains the name, use, PHP to determine whether form forms submitted, PHP won ...