PHP website Development Common 8 tips, PHP Web development Tips
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, name
Copy code code 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, then the
copy Code code is as follows:
if (! empty ($_post[' checkbox ')) {
$expr = "'" . Join ("', '", $_post[' checkbox ']). ".";
$sql = "SELECT * from Tbl_name where field in ($expr)";
}
3, PHP determines whether the form form is submitted
Copy code code as follows:
$action = $HTTP _post_vars[" Button1 "];
if ($action = = "Submit")
{
Perform form actions
}
Else
{
Read default values
}
4. PHP gets the string length
Copy the Code code as follows:
Strlen ($myrow [1])
PHP URL Steering
Copy the Code code as follows:
Header ("Location:". $_server["Http_referer"]);
5. PHP Hyper-Global objects
Copy the Code code as follows:
<?php
$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
Copy the Code code as follows:
<?= $HTTP _server_vars["REMOTE_ADDR"]?>
8. PHP Gets the current time
Copy the Code code as follows:
<?php
echo Date ("y-m-d g:i:s");
?>
Date ("Y year M month D Day")
Date ("Y-n-j")
http://www.bkjia.com/PHPjc/958253.html www.bkjia.com true http://www.bkjia.com/PHPjc/958253.html techarticle PHP Website Development Common 8 tips, PHP Web Development tips PHP is a service-side scripting language for creating dynamic Web pages. As with ASP and ColdFusion, users can mix ...