What is the best way to display the page title as text on a PHP page?

To display the page title as text on a PHP page, you can simply echo out the title within the HTML markup using PHP. This can be achieved by setting the title in a variable and then echoing it within the <title> tag in the HTML code of the page.

&lt;?php
$title = &quot;Page Title&quot;;
?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt;
    &lt;p&gt;This is the content of the page.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;