ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Why we write "exit ; " after redirect command ? header("Location: http://www.url.com" ) ; exit ;

user-image
تم إضافة السؤال من قبل Adel Ezat Fawzy Ellozy , Webdeveloper. , Saudi Arabian Maritiem Sports Federation
تاريخ النشر: 2017/03/06
Moeed Nisar
من قبل Moeed Nisar , Senior Web Designer & Developer , Intelligent Solutions Pvt. Ltd

just to make sure that the code after redirect line will not be executed.

Kamal Hasija
من قبل Kamal Hasija , Web Developer , The Brihaspati Infotech Pvt. Ltd.

Hi @Adel SIr, thanks alot for the this invitation again.

Why we write "exit ; " after redirect command ?

I think the 'header' is only a line of data asking the browser to redirect. We can use this to prevent from the recipient to perform the special hacking skills.

In details, Yes, always. The header is only a line of data asking the browser to redirect. The rest of the page will still be served by PHP and can be looked at by the client by simply preventing the header command from executing.That is easy enough to do with a command-line client like wget, for example, by simply telling it not to follow redirects.Bottom line: If you don't prevent it, PHP will send out the whole body even after a header call. That body is fully available to the recipient without any special hacking skills.

 

Regards,

 

BK Shah
من قبل BK Shah

When You redirect the page using header function we have Make sure that code below does not get executed when we redirect. Because even you redirect the page code does still execute if you do not exit the execution of script. Thought it may not visible after redirection but code still execute and may behaiv unexpectedly because it execute in server client may not get notice.

alaa liswe
من قبل alaa liswe , ِAdministrative Assistant , Arab Open University

adding exit after header is to make sure that code after it won't be executed

medhatmahmoud mahmoud
من قبل medhatmahmoud mahmoud , Web Designer , Connect Computer Service Co

to make sure that code below does not get executed after we redirecte to another page

himanshu patel
من قبل himanshu patel

Check https://www.acunetix.com/blog/articles/html-form-found-in-redirect-page/ which shows best answer for that.

المزيد من الأسئلة المماثلة