PHP website Development Common 8 Tips _php Tutorial

Source: Internet
Author: User
Tags echo date php form php website

PHP Web site development commonly used in 8 tips


This article mainly introduces the PHP Web site development commonly used in 8 tips, this article explains the name, use, PHP to determine whether form forms submitted, PHP get string length, PHP super-global objects and other content, the need for friends can refer to the next

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. Naming

The code is 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, the

The code is as follows:


if (! empty ($_post[' checkbox '))) {
$expr = "'". Join ("', '", $_post[' checkbox ']). ".";
$sql = "SELECT * from Tbl_name where field in ($expr)";
}


3, PHP to determine whether form forms submitted

The code is as follows:


$action = $HTTP _post_vars["Button1"];

if ($action = = "Submit")
{
Perform form actions
}
Else
{
Read default values
}


4. PHP gets the string length

The code is as follows:


Strlen ($myrow [1])


PHP URL Steering

The code is as follows:


Header ("Location:". $_server["Http_referer"]);


5. PHP Hyper-Global objects

The code is as follows:


$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

The code is as follows:



8. PHP Gets the current time

The code is as follows:


echo Date ("y-m-d g:i:s");
?>
Date ("Y year M month D Day")
Date ("Y-n-j")

http://www.bkjia.com/PHPjc/958132.html www.bkjia.com true http://www.bkjia.com/PHPjc/958132.html techarticle PHP Web site development commonly used in 8 tips This article mainly introduces the PHP Web site development commonly used in 8 tips, this article explains the name, use, PHP to determine whether form forms submitted, PHP won ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.