PHP website Development Common 8 tips, PHP Web Development Tips _php Tutorial

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

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

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