What is the correct way to add a button in the php file

0

I need to put a button in my php file where I will use it to register. Follow the code.

echo "<button type=\'"button"'\ class=\'"btn btn-default btn-lg"'\>";
        echo "<span class=\'"glyphicon glyphicon-plus"'\ aria-hidden=\'"true"'\></span> Inserir";
    echo "</button>";

What is the right way to do it?

    
asked by anonymous 01.06.2015 / 14:18

2 answers

2

You do not need this, Renan. Close the PHP routine with ? > and add the button in the same HTML language.

But if it's really necessary to do what you want:

echo "<button type='button' class='btn btn-default btn-lg'><span class='glyphicon glyphicon-plus' aria-hidden='true'></span> Inserir </button>";

Always think like this:

"" "

or

'' '     
01.06.2015 / 14:22
2

Try to use more html and less php. An example:

....
?>
<button type="button" class="btn btn-default btn-lg <?php echo $algumaClasse; ?>">
    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
        <?php echo $algumaAcaoParaBotao; ?>
</button>
<?php
....

This would be the best way.

    
01.06.2015 / 14:27