8 tips commonly used in PHP website development_PHP tutorial

WBOY
Release: 2016-07-13 10:06:36
Original
794 people have browsed it

8 tips commonly used in PHP website development

This article mainly introduces 8 tips commonly used in PHP website development. This article explains naming, usage, PHP Determine whether the Form form is submitted, PHP obtains the string length, PHP super global object, etc. Friends who need it can refer to it

PHP is a server-side scripting language used to create dynamic WEB pages. Like ASP and ColdFusion, users can use a mixture of PHP and HTML to write WEB pages. When a visitor browses to the page, the server will first process the PHP commands in the page, and then transmit the processed results together with the HTML content to Access browser. But unlike ASP or ColdFusion, PHP is an open source program with good cross-platform compatibility. Users can run PHP on Windows NT systems and many versions of Unix systems, and can run PHP as a built-in module of the Apache server or as a CGI program. This article summarizes 8 tips commonly used in daily PHP development.

PHP batch gets the checkbox value

1. Naming

The code is as follows:


$expr = join(“,”, $_POST['checkbox']);
$sql = “select * from tbl_name where field in ($expr)”;
}
If the field participating in the control is numeric, then

The 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 is submitted

The code is as follows:


$action=$HTTP_POST_VARS["Button1"];

if($action=="Submit")
{
//Perform form operations
}
else
{
//Read default value
}


4. PHP gets the string length

The code is as follows:


strlen($myrow[1])
PHP Url redirect

The code is as follows:


Header(“Location: “.$_SERVER["HTTP_REFERER"]);
5. PHP super global object

The code is as follows:


$a = 1;
$b = 2;
function Sum()
{
$GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
}
Sum();
echo $b;
?>
6. PHP form value collection

If method="get" use $_GET["test"] instead of $test

If method="post" use $_POST["test"] instead of $test

7. Get the current IP with PHP

The code is as follows:



8. Get the current time with PHP

The code is as follows:


echo date(“Y-m-d G:i:s”);
?>
date("Y year m month d day")
Date (“Y-n-j”)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/958132.htmlTechArticle8 tips commonly used in PHP website development This article mainly introduces 8 tips commonly used in PHP website development Tips, this article explains naming, usage, PHP judging whether the Form form is submitted, PHP getting...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!