Question:

Can an html code be embedded INSIDE php tags? ?

by  |  earlier

0 LIKES UnLike

Can i do this using PHP?

<?php

<html>

//Put HTML stuff here//

?>

 Tags:

   Report

4 ANSWERS


  1. Yes.

    However it is done using the echo command:

    &lt;?php

    echo &quot;&lt;html&gt;&quot;

    echo &quot;//Put HTML stuff here//&quot;

    ?&gt;


  2. An example of a link echoed with php.

    &lt;?php

    $var1 = &quot;yahoo&quot;;

    $var2 = &quot;http://www.yahoo.com&quot;;

    echo &quot;&lt;a name=&#039;var1&#039;  id=&#039;var1&#039;  href=&#039;var2&#039;&gt;Click for Yahoo.com&lt;/a&gt;&quot;;

    ?&gt;

  3. No, but what you can do is this:

    &lt;?php

    echo &quot;&lt;html&gt; *HTML STUFF HERE*&quot;;

    ?&gt;

    As long as you use the echo statement you can put in HTML.  

  4. You don&#039;t need to echo HTML inside PHP tags. You can close the PHP tags and write your HTML as normal. It just depends on what you are doing for what would be the most efficient.

    &lt;?php for($i=0; $i&lt;10;$i++){ ?&gt;

    &lt;strong&gt;This is repeated 10 times.&lt;/strong&gt;&lt; br /&gt;

    &lt;?php }?&gt;

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.