Answers for "How to use php to set title"

PHP
1

php title

function set_page_title(){
  global $page_title; 
  /*
    you should make the variable global so the function can access it and set it to the page title
    otherwise you will get an error.
  */
  if(isset($page_title)){ /*Check if my code has that variable*/
    echo $page_title;
  }
  else{
    echo "Page Title";
  }
}
/*
  HTML Layout
  <!DOCTYPE html>
  <head>
    <title><?php set_page_title() ?></title>
  </head>
  ...
*/
Posted by: Guest on June-14-2021
0

How to use php to set title

//1. Simply add $title variable before require function
<?php

$title = "Your title goes here";
require("header.php");

?>
  
  
//2. Add following code into header.php

<title><?php echo $title; ?></title>
Posted by: Guest on August-07-2021

Code answers related to "How to use php to set title"

Browse Popular Code Answers by Language