Message returning session user name using str_replace [duplicate]

0

I need some help to put the username at the top of the page. In php I was able to do it, (if you give an echo "$ username" it works) but it loses all formatting, so I need to do a replace in html. See

if (Session::getValue('logado')):

            switch (Session::getValue('departamento')) {
                case '1':

                    $menu = 'menu/admin.html';

                    $nomeusuario = $_SESSION['nome'];

                    $string = 'Olá ' . $nomeusuario . ' seja bem vindo!';

                    $nova = str_replace('#TMSG#', $nomeusuario, $string);

                    var_dump($nova);
    
asked by anonymous 16.02.2016 / 17:56

1 answer

1

So I know you want to str_replace , but it's possible to echo :

You should go to the desired part of the site and use:

<?php 
  echo "$nomeusuario seja bem vindo(a)!";
?>
  

Ta but will go unformatted

Simple to use CSS:
EXAMPLE:
HTML:

<div id="saudacao">
<?php 
  echo "$nomeusuario seja bem vindo(a)!";
?>
</div>

CSS:

#saudacao {
    color: red;
    font-family: Arial;
    font-size: 20px;
}

To put a size place within a <h>

As I said at the beginning, I know that was not how you asked for it, but that's how I always used it. I hope I have helped.

    
16.02.2016 / 18:49