How do I put an html tag inside the php code to format the text there?

3

I have the following code and wanted to put the <font> </font> tag for example to format the user.

<?php
    session_start();
    echo "Usuario: ". $_SESSION['usuarioNome'];    
?>
    
asked by anonymous 17.06.2017 / 12:16

2 answers

3

Add the HTML to this string, so for example:

<?php
    session_start();
    echo "<strong>Usuario:</strong> ". $_SESSION['usuarioNome'];    
?>

This will appear in the browser like this:

  

User: Lauriana

    
17.06.2017 / 12:24
1

Closes the php tag, writes the html normally, and calls the variable with an echo $ nameVar. In the case, I created a p, and inside it I added a span to customize what is needed from css.Cor, font, margin and etc.

<?php
    session_start();

    // atribuí uma variável ao teu _SESSION.
    // Não precisava, só quis reduzir o código de chamada.
    $username = $_SESSION['usuarioNome'];    
?>

<p>
    Olá,
        <span class="user-name">
            <?php
                // Escreve a variável
                echo $username;
            ?>
        </span>
</p>

In your css file you add the class added to span.

<style>
    .user-name{ font-weight: bold; }
</style>

It will display like this:

  

Hello, Hugo

    
17.06.2017 / 14:22