How to display string values within a table using PHP ? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 7 Likes Like Report A table is an arrangement of data in rows and columns, or possibly in a more complex structure. Tables are widely used in communication, research, and data analysis. Tables are useful for various tasks such as presenting text information and numerical data.Tables can be used to compare two or more items in the tabular form layout.Tables are used to create databases. Approach: Use HTML table elements inside PHP echo to print the string values in a table. We can write HTML tags inside a PHP script to display the output rendered as an HTML component. PHP code: PHP <?php // Declaration of strings $var1 = "Geeksforgeeks"; $var2 = "Priyank"; // Display HTML table using PHP echo // Use $variable_name to use a string // in code echo "<table border=1 cellspacing=1 cellpadding=1> <tr> <td><font color=green>$var1</font></td> <td>is best learning platform</td> </tr> <tr> <td><font color=green>Written by</font></td> <td>$var2</td> </tr> </table>"; ?> Output:<table border=1 cellspacing=1 cellpadding=1> <tr> <td> <font color=green> Geeksforgeeks </font> </td> <td> is best learning platform </td> </tr> <tr> <td> <font color=green> Written by </font> </td> <td> Priyank </td> </tr> </table> If we run this code on a local server then the output will display in form of a table. Comment M mishrapriyank17 Follow 7 Improve M mishrapriyank17 Follow 7 Improve Article Tags : Web Technologies PHP PHP-string PHP-function PHP-Questions +1 More Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like