php

$_SERVER Use In Generating Dynamic URL and header function to redirect PHP

 $_SERVER is an array containing information lke header, url path. Entries are generated by web servers. It can help.

  • making dymamic redirection header location value.
  • make dynamic web links as per use
  • can provide you value from url dynamically to operate with variables as per requirement.

$host = $_SERVER[‘HTTP_HOST’]; // gives host link/  domain name. as per applied
$uri = rtrim(dirname($_SERVER[‘PHP_SELF’]), ‘/\\’); // directory name  in between weblink.
$urib = $_SERVER[‘PHP_SELF’]; // all values after domain name so in above dirname function is used to avoid ful value of url link 
$extra = ‘page.php’;

header(“Location: http://$host$uri/$extra”);

// 1) a way of dynamic generation of  link by contaction $host value, $ uri value 

2)  to redirect with header function

Leave a Reply

Your email address will not be published. Required fields are marked *

four × one =