This article summarizes 8 tips that are commonly used in PHP's daily development.
PHP Batch Gets the value of the checkbox
1, naming
<input type= ' checkbox ' name= ' checkbox[] ' Value=dwmyrow[banzhu]/>
2. Use
When the plan is treated as part of the SQL directive: if the field that participates in the control is numeric, the
if (! empty (_post[' checkbox ')) {
Expr = Join (",", _post[' checkbox '));
sql = "SELECT * from Tbl_name where field in (expr)";
}
If the field participating in the control is numeric, the
if (! empty (_post[' checkbox ')) {
expr = "'". Join ("', '", _post[' checkbox ']). "
sql = "SELECT * from Tbl_name where field in (expr)";
}
PHP determines whether form forms are submitted
action=http_post_vars["Button1"];
if (action== "submit")
{
To perform a form operation
}
Else
{
Reading default values
}
PHP gets string length
Strlen (Myrow[1])
PHP URL Turn
Header ("Location:". _server["Http_referer"]);
PHP Hyper Global Objects
<?php
A = 1;
b = 2;
function Sum ()
{
Globals["B"] = globals["a"] + globals["B"];
}
Sum ();
Echo b;
?>
PHP form Values
If mothod= "get" replaces test with _get["test"
If mothod= "POST" replaces Test with _post["test"
PHP Gets the current IP
<?=http_server_vars["REMOTE_ADDR"]?>
PHP Gets the current time
<?php
echo Date ("y-m-d g:i:s");
?>
Date ("Y year M month D Day")
Date ("Y-n-j")