Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo in PHP, HTML tags

Tags:

html

php

echo

tags

I went through this before posting:

How can I echo HTML in PHP?

And I still couldn't make it work.

I'm trying to echo this:

<div>
    <h3><a href="#">First</a></h3>
    <div>Lorem ipsum dolor sit amet.</div>
    </div>
<div>

But I still can't find a way to make the tags "" and '' disappear. What do I have to do?

like image 441
Trufa Avatar asked Oct 14 '10 08:10

Trufa


People also ask

Can I echo HTML in PHP?

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

Does echo work in PHP?

In PHP, you will use echo to output one or more expressions. It's important to understand that echo is not a function but is a language construct. The arguments echo accepts are a list of expressions separated by commas. Unlike other language constructs, echo does not have a return value.

How do you escape HTML tags in PHP?

The strip_tags() function strips a string from HTML, XML, and PHP tags. Note: HTML comments are always stripped. This cannot be changed with the allow parameter. Note: This function is binary-safe.


1 Answers

<?php

echo '<div>
 <h3><a href="#">First</a></h3>
 <div>Lorem ipsum dolor sit amet.</div>
</div>
<div>';

?>

Just put it in single quotes.

like image 147
William Macdonald Avatar answered Sep 16 '22 16:09

William Macdonald