PHP echo html skills

 PHP echo html skills is very simple, since it is used PHP echo structure, then in addition to mere echo html, you can also echo the PHP 's variable value, basic PHP dynamic web design, often use to The skills of PHP echo html are more advanced and start to be prototyped. It is relatively rare to directly use echo html processing methods. This article focuses on basic PHP echo html skills, so that readers and friends before learning advanced prototype design , Can quickly get started with basic PHP design.


PHP echo html implementation example 1. Basic HTML tags
<?php
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding declaration  
echo'here is a string<br>';
echo ' <a href="#">Here is a hyperlink</a><br>';
echo'<b>Here is bold text</b><br>';
echo "<input type='text' value ='Text input field'><br>";
echo "<input type='button' value='This is a button'>";
?>
Example output
Here is the string,
here is the hyperlink,
here is the bold text

Example one is an introductory echo html technique. The first line of echo is a web page meta tag , which is used to declare the code of the web page, so that the subsequent echo traditional Chinese can be displayed smoothly, and then a series of HTML text or tags, such as hyperlinks , Bold text, HTML input text, text input fields , and HTML button buttons can all be easily output to the screen through echo , but it should be noted that when there are quotation marks in HTML tags, use double quotation marks at the outermost layer to avoid Single quotes inside, so as not to make mistakes in browser judgment.

PHP echo html implementation example 2: Output variable number string through string concatenation operator
<?php
echo'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'; //Web page encoding declaration  
$string1='<b>';
$string2=' </b>';
$string3='Here is bold font';
$string4='Here is normal font';
echo $string4.$string1.$string3.$string2.$string4;
?>
Example output
Here is the normal font, here is the bold font, here is the normal font
The second example shows how to use the built-in string concatenation operator in PHP to concatenate the contents of different strings into a new string, and then use echo to output the string or HTML to output the new string to On the web, this technique is often applied to situations where multiple variables must be combined. The so-called string concatenation operator is the half-shape dot (.).

Post a Comment

0 Comments