Some techniques used in PHP development

Source: Internet
Author: User
Tags current time echo date empty numeric join php form

PHP Batch Gets the value of the checkbox

1, naming

The following are the referenced contents:

<input type= ' checkbox ' name= ' checkbox[] ' value= $dwmyrow [Banzhu]/>

2. Use

When the plan is treated as part of the SQL directive: if the field that participates in the control is numeric, the

The following are the referenced contents:

if (! empty ($_post[' checkbox ')) {
$expr = Join (",", $_post[' checkbox '));
$sql = "SELECT * from Tbl_name where field in ($expr)";
}
If the field participating in the control is numeric, the

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

PHP determines whether form forms are submitted

The following are the referenced contents:

$action = $HTTP _post_vars["Button1"];
if ($action = = "Submit")
{
To perform a form operation
}
Else
{
Reading default values
}

PHP gets string length

Strlen ($myrow [1])

PHP URL Turn

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

PHP Hyper Global Objects

The following are the referenced contents:

<?php
$a = 1;
$b = 2;
function Sum ()
{
$GLOBALS ["b"] = $GLOBALS ["a"] + $GLOBALS ["B"];
}
Sum ();
Echo $b;
?>

PHP form Values

The following are the referenced contents:

If mothod= "get" replaces $test with $_get["test"
If mothod= "POST", replace $test with $_post["test"

PHP Gets the current IP

<?= $HTTP _server_vars["REMOTE_ADDR"]?>

PHP Gets the current time

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



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.