Comparison of php header and redirect in asp_PHP tutorial
To implement redirection in asp, the response.redirect function is used:
An example of usage:
response.redirect "../test.asp"
There is a similar function in php: header
An example of usage:
header("location:../test.php");
But there is a difference between the two.
ASP’s redirect function can work after sending the header file to the customer.
Such as
<%response.redirect "../test.asp"%>
Check if the following example code in php will report an error:
header("location:.. /test.php");
?>
You can only do this:
header("location:../ test.php");
?>
...
i.e. header No data can be sent to the client before the function.
Look at the following example:
asp in
< %
response.redirect "../a.asp"
response.redirect "../b.asp"
%>
The result is to redirect the a.asp file. What about
php?
header("location:../a.php");
header("location:../ b.php");
?>
We found it redirected b.php.
It turns out that after executing redirect in asp, the following code will not be executed.
After executing the header, php will continue to execute the following code.
In this regard, the header in php is important. Orientation is not as good as redirection in asp. Sometimes we cannot execute the following code after redirection:
Generally we use
if(...)
header("...");
else
{
...
}
But we can simply use the following method:
if(...)
{ header("..." );break;}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Logging in CakePHP is a very easy task. You just have to use one function. You can log errors, exceptions, user activities, action taken by users, for any background process like cronjob. Logging data in CakePHP is easy. The log() function is provide

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
