Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

638
Visualizações
Can't make text bold in PHP

I'm new to PHP and trying to write a PHP script to output some text in boldface. I've tried every combination of echo / print, < b> / < strong> but no matter what, the output is always like this: <strong>Text</strong>

<?php
    print "<strong>Text</strong>";
?>

Why is this happening? I'm using PhpStorm, could there be a setting I have to fix?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Make sure your are opening your php file in your localhost. For example your filename is index.php you should run it at localhost/index.php. PHP scripts do not run when u just open it in your browser like HTMLs.

Can you add the current URL you are working with?

over 4 years ago · Santiago Trujillo Relatório

0

check that which content-type it is. Make sure the text/html is correct. And also you should put some screenshots of your web server configuration.

over 4 years ago · Santiago Trujillo Relatório

0

Maybe you dont have the correct settings in the project for the HTML to be loaded properly, e.g. not the correct meta settings Try this:

<html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <?php
      print "Text\n";
      print "<b>Text</b>";
    ?>
  </body>
</html>

If it doesn't work, try this meta tag instead:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

UPDATE:

The reason this could happen, is because you have a PHP file, but you are using HTML within your PHP file - which is okay, but you have to render/return the php within html tags. For this to be rendered, you have to render the HTML within an HTML tag, or the HTML tags wont be rendered. Right now you are rendering HTML without having referenced the HTML anywhere.

What you could do is in the php tag in the html file, within body, specify a function:

<b><?php outputtext(); ?></b>

In your PHP file you specify the function as

function outputtext() {
  return "hello world";
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda