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
- <input type='checkbox' name='checkbox[]' value=$dwmyrow[banzhu] />
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
- <?php
- $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
- <? = $ HTTP_SERVER_VARS ["REMOTE_ADDR"]?>
- PHP gets the current time
-
- <? Php
- Echo date ("Y-m-d G: I: s ");
- ?>
- Date ("Y, m, D ")
- Date ("Y-n-j ")
I hope this article will help you.