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

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

藏色散人
Release: 2023-04-10 12:32:02
Original
5930 people have browsed it

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:

<?php
$a=5000;
$b=6000;
$c=7000;
Copy after login

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

echo "<table border=1 cellspacing=0 cellpading=0>
<tr> <td><font color=blue>A的工资是</td> <td>$a$</font></td></tr> 
<tr> <td><font color=blue>B的工资是</td> <td>$b$</font></td></tr>
<tr> <td><font color=blue>C的工资是</td> <td>$c$</font></td></tr>
</table>";
Copy after login

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 through HTML 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 click PHP 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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template