php form of php code embedded in Web pages

1. Adding PHP scripts in HTML tags

 

In the process of coding in Web, PHP is an embedded HTML language that can be used with mixing, you can always add a PHP script tag in HTML <? PHP ...?> , All text between two markers will be interpreted as PHP, and any text would mark is considered to be outside the ordinary HTML.

For example, the identifier tag is added in PHP <body>, using an include statement references the index.php external file, the code is shown below: marble maintenance mechanical member

1

2

3

<?php

    include(" index.php ");       //引入外部文件

?>

Thousands of code, however, but how to do it to distinguish between HTML and PHP, PHP decomposition breaks (tags) like a pillar, accurately mark the start and end position of the PHP script. There are four character decomposition allows PHP embedded into HTML.

(1) <php and??>: PhP standard character decomposition.

(2) <and??>: Decomposition abbreviated character.

(3) <script language = "php"> and </ script>: JavaScript / VBScript exploded character style

(4) <% and%>: ASP decomposition character.

Wherein the first and the second is the most commonly used method; method of the third embodiment is similar to JavaScript embedded; ASP fitted manner similar to the fourth embodiment.

Note: To use PHP support <??> <%%> mode, the following settings are required in the configuration file PHP.ini in:

short_open_tag = on;

asp_tags = on;

SUMMARY exploded between a pair of symbols "<" and ">" are PHP code, outside of the inner wing HTML element belongs.

PHP statement terminator

PHP statement terminator semicolon ";", i.e., after every one PHP code will need to add ";" indicates the end of the statement.

PHP is case sensitive, ignoring the statements of spaces, tabs, carriage returns, so you can make the program a good indentation style.

2. The value of the form element attribute assignment

In the process of Web development, it is generally necessary to form element attribute value assignment to get the default value of the form elements. For example, the form element is hidden field assignment, just to the assigned property value added to the value after it, the code examples are as follows:

1

2

3

<?php

   $hidden="abc001"                          // 为变量 $hidden 赋值

?>

Hidden field values:

1

<input type="hidden" name="id" value="<?php echo $hidden;?>">

As can be seen from the above code, is first given an initial value of the variable $ hidden, then assign the value of $ hidden hidden field. In the program development process, some hidden fields to store information or parameters without showing the need to send regular use.

Let's briefly talk about what is hidden fields

Hidden field is used to collect or transmit information invisible elements, for visitors to the web page, the hidden field is not visible. When the form is submitted, hidden fields will be sending information to the server with the name and value you defined when setting.

Hidden field advantage

  1, does not require any server resources.

  2, supports a wide range, any clients support a hidden field.

  3, simple, hidden fields belong to HTML controls, as there is no need to require programming knowledge as server controls.

  Insufficient hidden field

  1, it has a high security risk.

  2, a simple memory structure.

  3, if more stores larger value will cause performance problems.

  4. If you hide too many domains, some clients are prohibited.

  5, hidden field data stored on the server, without being stored in the client.

Note that if the development, page hidden field too, these hidden fields are stored in the server. When the client browser page, there will be some firewalls scanned pages to ensure safe operation of the system, if too many hidden field of the page, then the firewall may prevent some features of the page.

These are the details php php form of embedded code in a Web page,

Guess you like

Origin www.cnblogs.com/furuihua/p/12133950.html