PHP experience sharing: common tips _ PHP tutorials

Source: Internet
Author: User
Tags php form
PHP experience sharing: common tips. PHP is short for HypertextPreprocessor. PHP is an embedded HTML language and a script language that is executed on the server side to embed HTML documents, PHPIs short for Hypertext Preprocessor. PHP is an embedded HTML language. it is a scripting language that executes HTML documents embedded on the server. it is widely used in a style similar to C language. This article summarizes eight tips commonly used in daily PHP development.

1. name

 
 

2. use

When the plan is considered as part of an SQL command: If the field involved in the control is numeric

 
 
  1. if(! emptyempty($_POST['checkbox'])) {
  2. $expr = join(",", $_POST['checkbox']);
  3. $sql = "select * from tbl_name where field in ($expr)";
  4. }

If the field involved in the control is numeric

 
 
  1. if(! emptyempty($_POST['checkbox'])) {
  2. $expr = "'".join("','", $_POST['checkbox']).".";
  3. $sql = "select * from tbl_name where field in ($expr)";
  4. }

PHP checks whether the Form is submitted

 
 
  1. $ Action = $ HTTP_POST_VARS ["Button1"];
  2. If ($ action = "submit ")
  3. {
  4. // Execute the form operation
  5. }
  6. Else
  7. {
  8. // Read the default value
  9. }

PHP obtains the string length

 
 
  1. strlen($myrow[1])

PHP Url redirection

 
 
  1. Header("Location: ".$_SERVER["HTTP_REFERER"]);

PHP Super global object

 
 
  1. $a = 1;
  2. $b = 2;
  3. function Sum()
  4. {
  5. $GLOBALS["b"] = $GLOBALS["a"] + $GLOBALS["b"];
  6. }
  7. Sum();
  8. echo $b;
  9. ?>

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

 
 
  1. PHP gets the current time
  2. Echo date ("Y-m-d G: I: s ");
  3. ?>
  4. Date ("Y, m, d ")
  5. Date ("Y-n-j ")

I hope this article will help you.


Http://www.bkjia.com/PHPjc/445750.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/445750.htmlTechArticlePHP, short for Hypertext Preprocessor. PHP is an embedded HTML language. it is a script language that is executed on the server to embed HTML documents ,...

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.