how to create dynamic page title in php
PHP dynamic title
As you know PHP is a server side programming language so you can change the title of web page dynamically.
<!DOCTYPE html> <html> <head> <title> <?php $a=array ( "first title", "Second title", " Thirrd title", "fourth title" ); $i=rand(0,3); echo "$a[$i]"; ?> </title> </head> <body> </body> </html>
You can check dynamic title by refreshing the page again and again.
Note: In the place of array you can use switch case or if-else as per your need.
PHP Dynamic title switch example
<!DOCTYPE html> <html> <head> <title> <?php $i=rand(1,3); switch($i) { case 1: echo "First title"; break; case 2: echo "Second title"; break; case 3: echo "third title"; break; default: echo "Nothing"; } ?> </title> </head> <body> </body> </html>