Home »
PHP »
PHP programs
How to make text bold in PHP?
Making text bold in PHP: In this article, we are going to learn how to bold text in PHP programming language?
Submitted by Kongnyu Carine, on May 27, 2019 [Last updated : March 12, 2023]
Sometimes we might want to display text with style. That it's font, color, make it bold, italic, underlined and many more. Adding whatever style is all based on the message that we want to pass across or getting someone's attention.
In this article, we will learn how to bold text in PHP? When we bold text we make the text stand out than another. We can bold a single word, a phrase, a sentence, a particular paragraph or a letter.
We use the html tag <b>...</b> to bold text inside the PHP scripts.
Example
In this example, we will learn how to bold a sentence, a word, a character and a paragraph in PHP?
PHP code to make text bold
<?php
//this is a bold sentence
echo "<b> this is a bold sentence</b>";
//this is a bold word
echo "<br> this is a bold word<b> john</b>";
//this is a bold character
echo "<br>this is a bold character<b> A</b>";
//this is a bold paragraph
echo "<br> this is a bold paragraph<b>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,<br>
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.<br>
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex <br>
ea commodo consequat. Duis aute irure dolor in </b>";
?>
Output
this is a bold sentence
this is a bold word john
this is a bold character A
this is a bold paragraph Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
ea commodo consequat. Duis aute irure dolor in
In the above example, we use the following PHP topics:
Note
You can also use <strong>...</strong> instead of <b>...</b> tag. HTML <strong>...</strong> tag defines the text with strong importance.
PHP Basic Programs »