Home>Article>Backend Development> Learn quickly! Output HTML table and display variable values through PHP

Learn quickly! Output HTML table and display variable values through PHP

藏色散人
藏色散人 Original
2021-07-29 11:50:14 5814browse

Regarding the application between PHP and HTML, I gave you a brief introduction in the previous article. Friends who are interested can click ->《Interesting! Set PHP variable to anchor text》 in HTML. So to get back to the subject, today’s topic is to teach you how to output HTML tables and display variable values through PHP. Newbies please stay, and experts please stop and give guidance~

PHP outputs HTML tables and displays variable values :

Old rules, step by step

First create a PHP sample file, name it whatever you want~

For example, I am demo.php;

Then define three variables, namely $a, $b, $c, and assign the values as you like~ (Note: In PHP, these letters are called variables)

are as follows:


      

Then we use echo to output the table form. The code is as follows:

echo "
A的工资是 $a$
B的工资是 $b$
C的工资是 $c$
";

We open the browser and run the demo.php file to view the output results, as follows:

Learn quickly! Output HTML table and display variable values ​​through PHP

An extremely simple salary form is now available!

Regarding the use of table tags, you can learn directly throughHTML video tutorial.

By the way, let me summarize the issues about PHP variable declaration:

Variables in PHP are "containers" used to store information. Variables can be very short names (such as x and y) or a more descriptive name (such as age, carname, totalvolume), such as $a, $b, $c in the above example.

The scope of a variable is the part of the script where the variable can be referenced/used, and there are four different variable scopes in PHP, namely local, global, static, and parameter. (For detailed introduction, please clickPHP Variables)

Although the above examples are very simple, for those who are just getting started, you may be able to get some help from them. Thank you for reading~

Related recommendations: "PHP interview questions summary (collection)"

The above is the detailed content of Learn quickly! Output HTML table and display variable values through PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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