Tips for daily php development

Source: Internet
Author: User
Tags echo date php form

PHP retrieves checkbox values in batches

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 (! Empty ($ _ 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 (! Empty ($ _ 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 ")

Related Article

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.