Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write html code inside <?php ?>, I want write html code within the PHP script so that it can be echoed from Backend [closed]

Tags:

html

php

I want to create table inside php script .. Is there any way that i could create table inside php script.?

<?php html code to create table ?> 
like image 409
Karan Bhatia Avatar asked Aug 09 '13 04:08

Karan Bhatia


People also ask

How can I write HTML code inside PHP?

Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the PHP. Step 2: Now, we have to place the cursor in any tag of the <body> tag where we want to add the code of PHP. And, then we have to type the start and end tag of PHP.

Can we write script inside PHP?

You can execute Javascript through PHP by calling javascript code/function as a string in PHP and send it to the client browser to execute.

Can you echo HTML in PHP?

Using echo or print: PHP echo or print can be used to display HTML markup, javascript, text or variables.


1 Answers

You can do like

HTML in PHP :

<?php      echo "<table>";      echo "<tr>";      echo "<td>Name</td>";      echo "<td>".$name."</td>";      echo "</tr>";      echo "</table>"; ?> 

Or You can write like.

PHP in HTML :

<?php /*Do some PHP calculation or something*/ ?>      <table>          <tr>              <td>Name</td>              <td><?php echo $name;?></td>          </tr>      </table> 


<?php /*Do some PHP calculation or something*/ ?> Means:
You can open a PHP tag with <?php, now add your PHP code, then close the tag with ?> and then write your html code. When needed to add more PHP, just open another PHP tag with <?php.

like image 91
Gautam3164 Avatar answered Oct 08 '22 14:10

Gautam3164