在PHP中使用元刷新标记进行重定向而不是使用header()函数是不错的做法吗? [英] Is it good practise to use meta refresh tags for redirects instead of header() function in php?
问题描述
我必须在我的脚本中使用很多重定向,例如在用户登录后我需要将它们重定向到管理区域等等。但是我觉得不方便总是必须将标题功能放在顶部。因此,如果我使用元刷新标记作为我的重定向,那么根据最佳做法会让这些标记皱起眉头,还是可以接受?
function redirect($ location){
echo< meta http-equiv ='refresh'content ='0; url = $ location'/>;
/ strong> 维基百科明确指出: Meta刷新是一种劝阻网页浏览器在给定时间间隔后自动刷新当前网页或框架的劝阻方法..... 元刷新标记有一些缺点: I have to use redirects a lot in my scripts, for example after a user logs in I need to redirect them to the admin area, etc. But I find it inconvenient to always have to have the header function at the very top. So if I use the meta refresh tags for my redirects, is that something that would be frowned upon according to best practices or is it acceptable?
No. The Wikipedia clearly states: Meta refresh is a discouraged method of instructing a web browser to automatically refresh the current web page or frame after a given time interval..... Meta refresh tags have some drawbacks:
这篇关于在PHP中使用元刷新标记进行重定向而不是使用header()函数是不错的做法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< blockquote>
function redirect($location) {
echo "<meta http-equiv='refresh' content='0; url=$location' />";
}