PHP experience sharing: Common tips _php Tutorials

Source: Internet
Author: User
Tags php form vars
PHP, is the abbreviation of English Super Text preprocessing language hypertext preprocessor. PHP is an HTML embedded language, is a server-side implementation of embedded HTML document scripting language, language style has similar to C language, is widely used. This article summarizes the 8 tips commonly used in daily development of PHP.

1. Naming

 
  
  
  1. ' checkbox ' name= ' checkbox[] ' value= $dwmyrow

2. Use

When the plan is part of a SQL instruction: if the field that participates in the control is numeric, the

 
  
  
  1. Ifemptyempty($_post[' checkbox '])) {
  2. $expr = Join (","$_post[' checkbox ']);
  3. $sql"select * from Tbl_name where field in ($expr)";

If the field that participates in the control is numeric, the

 
  
  
  1. Ifemptyempty($_post[' checkbox '])) {
  2. $expr"'". Join ("', '"$_post[' CheckBox ']). "." ;
  3. $sql"select * from Tbl_name where field in ($expr)";
  4. }

PHP determines whether a form form is submitted

 
  
  
  1. $action = $HTTP _post_vars ["Button1"];
  2. if ($action= ="Submit")
  3. {
  4. }
  5. Else
  6. {
  7. }

PHP Gets the string length

 
  
  
  1. strlen ($myrow

PHP URL Steering

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

PHP Hyper-Global objects

 
  
  
  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 Values

If mothod= "get" uses $_get["test" instead of $test
If mothod= "POST" uses $_post["test" instead of $test

PHP Gets the current IP

 
  
  
  1. $HTTP _server_vars ["REMOTE_ADDR"]?>
  2. PHP Gets the current time
  3. echodate("y-m-d g:i:s");
  4. ?>
  5. Date ("y year M D Day")
  6. Date ("Y-n-j"

Hope that through the introduction of this article, can bring you help.


http://www.bkjia.com/PHPjc/445750.html www.bkjia.com true http://www.bkjia.com/PHPjc/445750.html techarticle PHP, is the abbreviation of English Super Text preprocessing language hypertext preprocessor. PHP is an HTML embedded language, is a server-side execution of embedded HTML document script language, ...

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