PHP dynamic website development tips _ PHP Tutorial

Source: Internet
Author: User
Tags php dynamic website php form
Tips for PHP dynamic Website Development. Many programmers are using 1. naming inputtypecheckboxnamecheckbox [] value $ dwmyrow [banzhu] 2. when using a plan as part of an SQL command: If many programmers are using 1. name

  1. <Input
  2. Type = 'checkbox'
  3. Name = 'checkbox []'
  4. Value = $ dwmyrow [banzhu]
  5. />

2. use

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

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

If PHP dynamic website development says that the field involved in control is numeric

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

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 dynamic website development PHP get string length

 
 
  1. strlen($myrow[1])

PHP Url redirection

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

Super global object in PHP dynamic Website Development

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

PHP form value

If method = "get", replace $ _ GET ["test"] with $ test.
If method = "post", replace $ _ POST ["test"] with $ test.

Obtain the current IP address when developing a PHP dynamic website

 
 
  1. =$HTTP_SERVER_VARS["REMOTE_ADDR"]
  2. ?>

PHP gets the current time

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

The above is a detailed explanation of PHP dynamic website development skills.


Example 1: name input type = 'checkbox' name = 'checkbox [] 'value = $ dwmyrow [banzhu]/2. when a plan is used as part of an SQL command: if you participate in the control...

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.