How to output string to HTML in php

不言
Release: 2023-04-04 21:02:01
Original
9163 people have browsed it

echo can output the string specified in the parameter. PHP needs to use echo to output the string to HTML. Let's take a look at the specific content.

How to output string to HTML in php

Let’s look at an example first

Output HTML tag

  

你好,先生。

Copy after login

The output result is as follows

你好,张三先生。
Copy after login
Copy after login
Copy after login

The value assigned to the variable $name will be expanded and displayed as part of the HTML.

It is also possible to assign HTML tags to variables and display them.

  

你好, $name 先生。"; echo $span; ?>

Copy after login

The output results are as follows:

你好,张三先生。
Copy after login
Copy after login
Copy after login

In the above results, Mr. Zhang San will be displayed in red.

The variable $span contains HTML tags. When echo is used to output, the label part is recognized as a normal HTML markup and displayed.

Form processing

By making the target of an HTML form a PHP file, you can use that PHP file to process the data sent from the form.

Create a form using HTML.

 
名称:
Copy after login

Fill out this form and press the submit button to send the form data to form.How to output string to HTML in php.

Output data from form

I will output the data sent from the form above.

For data sent using POST, you can get $_POST['Element Name'], and for data sent using GET, you can get $_GET['Element Name'].

Use echo output.

你好,先生。
Copy after login

Enter "Zhang San" in the above form and press the send button, it will be displayed as follows.

你好,张三先生。
Copy after login
Copy after login
Copy after login

This article ends here. For more exciting content, you can pay attention to the relevant column tutorials on the How to output string to HTML in php Chinese website! ! !

The above is the detailed content of How to output string to HTML in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!