PHP experience sharing: common tips. PHP is short for HypertextPreprocessor. PHP is an embedded HTML language and a script language that is executed on the server side to embed HTML documents,
PHPIs short for Hypertext Preprocessor. PHP is an embedded HTML language. it is a scripting language that executes HTML documents embedded on the server. it is widely used in a style similar to C language. This article summarizes eight tips commonly used in daily PHP development.
1. name
-
2. use
When the plan is considered as part of an SQL command: If the field involved in the control is numeric
- if(! emptyempty($_POST['checkbox'])) {
- $expr = join(",", $_POST['checkbox']);
- $sql = "select * from tbl_name where field in ($expr)";
- }
If the field involved in the control is numeric
- if(! emptyempty($_POST['checkbox'])) {
- $expr = "'".join("','", $_POST['checkbox']).".";
- $sql = "select * from tbl_name where field in ($expr)";
- }
PHP checks whether the Form is submitted
- $ Action = $ HTTP_POST_VARS ["Button1"];
- If ($ action = "submit ")
- {
- // Execute the form operation
- }
- Else
- {
- // Read the default value
- }
PHP obtains the string length
- strlen($myrow[1])
PHP Url redirection
- Header("Location: ".$_SERVER["HTTP_REFERER"]);
PHP Super global object
-
- $a = 1;
- $b = 2;
- function Sum()
- {
- $GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
- }
- Sum();
- echo $b;
- ?>
PHP form value
If mothod = "get", replace $ _ GET ["test"] with $ test.
If mothod = "post", replace $ _ POST ["test"] with $ test.
PHP obtains the current IP address
-
- PHP gets the current time
-
-
- Echo date ("Y-m-d G: I: s ");
- ?>
- Date ("Y, m, d ")
- Date ("Y-n-j ")
I hope this article will help you.
Http://www.bkjia.com/PHPjc/445750.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445750.htmlTechArticlePHP, short for Hypertext Preprocessor. PHP is an embedded HTML language. it is a script language that is executed on the server to embed HTML documents ,...