Redirection from one page to lớn another in PHP is commonly achieved using the following two ways:Using Header Function in PHP:The header() function is an inbuilt function in PHP which is used to sover the raw HTTPhường (Hyper Text Transfer Protocol) header lớn the client.
Bạn đang xem: Header
Syntax:header( $header, $replace, $http_response_code )Parameters: This function accepts three parameters as mentioned above sầu and described below:$header: This parameter is used khổng lồ hold the header string.$replace: This parameter is used to lớn hold the replace parameter which indicates the header should replace a previous similar header, or add a second header of the same type. It is optional parameter.Xem thêm: remove array item with index php
$http_response_code: This parameter hold the HTTP response code.Below program illustrates the header() function in PHP:Note: The die() or exit() function after header is mandatory. If die() or exit() is not put after after the header(‘Location: ….’) then script may continue resulting in unexpected behavior. For example, result in content being disclosed that actually wanted to lớn prsự kiện with the redirect (HTTP 301).Using JavaScript via PHP:The windows.location object in JavaScript is used to lớn get the current page address(URL) & lớn redirect the browser khổng lồ a new page. The window.location object contains the crucial information about a page such as hostname, href, pathname, port etc.Example:
Output:URL: https://ide.darkedeneurope.com/tryit.phpHostname: ide.darkedeneurope.comProtocal: https:PHP.. is a server-side scripting language designed specifically for web development. You can learn PHPhường from the ground up by following this PHP Tutorial and PHPhường Examples.
How to lớn exeđáng yêu PHP.. code using comm& line ?How to Insert Form Data inkhổng lồ Database using PHP ?Download tệp tin from URL using PHPHow to lớn convert array to lớn string in PHP ?How to get parameters from a URL string in PHP?
How to lớn exexinh tươi PHP.. code using command line ?How to lớn Insert Form Data into lớn Database using PHP ?Download tệp tin from URL using PHPHow to lớn convert array khổng lồ string in PHPhường ?How to get parameters from a URL string in PHP?
We use cookies lớn ensure you have the best browsing experience on our website. By using our site, youacknowledge that you have sầu read & understood ourCookie Policy và Privacy PolicyGot It !