Use HTML in PHP [duplicate]

1

I have the following code that is not working.

echo "<a href='memberarea.html'><span class="glyphicon glyphicon-lock"></span> Member area</a>"; 

I think I'm not doing well to incorporate HTML into PHP.

    
asked by anonymous 13.05.2017 / 10:34

3 answers

2

You need to escape the quotation marks or replace them with single quotation marks, since you are using quotation marks for echo.

Escaping the quotes:

echo "<a href='memberarea.html'><span class=\"glyphicon glyphicon-lock\"></span> Member area</a>"; 

Or:

echo "<a href='memberarea.html'><span class='glyphicon glyphicon-lock'></span> Member area</a>";
    
13.05.2017 / 12:08
1

If you use double quotation marks to define the string, you must use single quotes in the middle or escape:

echo "algo \"algo dentro de aspas\" algo";

or

echo "algo 'algo dentro de aspas' algo";

In your case it could be:

echo "<a href='memberarea.html'><span class='glyphicon glyphicon-lock'></span> Member area</a>";
    
13.05.2017 / 12:07
1

Actually, the code presented does not need to be written in php, it can be written in html itself:

<a href='memberarea.html'><span class="glyphicon glyphicon-lock"></span> Member area</a>

But if you want to put php, you should use a .php file to make use of:

-- script html aqui
<?php
    -- codigo php aqui
?>
-- continuação do script html
    
13.05.2017 / 21:11