PHP and MySQL Web Development Study notes Chapter 1-1.5 Getting Started

Source: Internet
Author: User
Tags configuration settings echo command php language php and mysql

The 1.PHP code can consist of the following four parts:

    1. Html
    2. PHP tags
    3. PHP statements
    4. Space

PHP tags usually start with "<?php", with "? > "End.

Four styles of 2.PHP markers

    1. XML style: <?php echo ' <p> Order processed.</p> ';? This is a recommended style for PHP, and server Administrators cannot disable this style of tagging, so this style of tagging is guaranteed to be available on all servers, which is especially important for applications that write different server environments.
    2. Short style: < Echo ' <p> Order processed.</p> ';? This style of marking is the simplest and follows the style of SGML (standard Universal Markup Language) processing instructions. To use this markup style, you must enable the Short_open_tag option in the configuration file, or enable the short mark option to compile PHP. This style is not recommended because it is not supported in the default settings for many environments.
    3. Script style: <script language = ' php> echo ' <p> Order processed.</p> '; </script>, this style is the longest, but people who are familiar with Iavascript or VBScript may be more accustomed to it.
    4. ASP style:: <% echo ' <p> Order processed.</p> '; %>, this style is the same as the ASP tag style. If Asp_tags is enabled in the configuration settings, it can be used, but the markup style is disabled by default.

3. Precautions

    1. In PHP statements, semicolons are used to separate statements. Missing semicolons is a common syntax error.
    2. In the PHP language, the spacer such as the carriage return, and the spaces and tabs are considered spaces. PHP will ignore them by default. So they are not applied to separate statements. To write code to a line, you can use the join operator "." To write in a single line of code. When sending output to the browser using the Echo command, you can use this connector to avoid writing multiple echo commands.
    3. the difference between single and double quotes: A single quote indicates that it is a string that will send the contents of the quotation mark to the browser, and the double quotes will parse the contents of the quotation marks, as the variable will replace it with its value.

4. Notes

Multiline comment: Start with "/*", End with "*/"

Single-line Comment: C + + style, beginning with "//", Shell scripting style, beginning with "#". A single-line comment is a comment from the beginning of the label to the end of the line.

5. Accessing the form

In PHP, you can access each form field in the form of a PHP variable, where the name of the PHP variable must match the name of the form field. The variable name for PHP starts with the $ symbol.

There are three ways to access form data through variables, depending on the PHP version and settings:

There are three ways to access the contents of the Tireqty domain:

    1. $tireqty; The short style is convenient, but you need to set the Register_globals configuration option to on, which is off by default for security reasons.
    2. $_post[' Tireqty ']; Medium Style recommended! Creating short versions of variable names based on medium style doesn't create a security problem.
    3. $HTTP _post_vars[' Tireqty ']; The lengthy style has been deprecated.

Medium style involves retrieving variables from one of the $_post, $_get, $_request arrays, and if the data is submitted through the POST method, the data entered in the Tireqty text box is saved in $_post[' Tireqty ', if submitted by the GET method, The data will be saved in $_get[' Tireqty '). In either case, the data can be obtained by $_request[' Tireqty '.

These arrays are called Super Global (Superglobal) variables.

6. methods for specifying strings

    1. Single quotation marks
    2. Double quotes
    3. Heredoc syntax

Interpolation: The operation of replacing a variable with a string is an interpolation (interpolation). This string can be quoted in double quotation marks.

Variables and text: a single quotation mark indicates that inside is a string that will send the contents of the quotation marks to the browser (in textual form), and the double quotation marks will parse the contents of the quotation marks, as the variable will replace it with its value.

Heredoc Syntax: Specifies the character tag of an end string to specify a long string. Such as:

Echo<<<theend

Line1

Line2

Line3

TheEND

The Heredoc string is interpolated, just like a double-quoted string.

PHP and MySQL Web Development Study notes Chapter 1-1.5 Getting Started

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.