Home > Backend Development > PHP Tutorial > Analysis of the specific method of querying a single component using PHP function header()_PHP tutorial

Analysis of the specific method of querying a single component using PHP function header()_PHP tutorial

WBOY
Release: 2016-07-15 13:29:26
Original
973 people have browsed it

How to use the specific content we will explain to you todayThe following is a script called calling.php:

<ol class="dp-xml">
<li class="alt"><span><span><!DOCTYPE HTML PUBLIC   </SPAN></SPAN><LI class=""><SPAN>"-//W3C//DTD HTML 4.0 Transitional//EN"   </SPAN><LI class=alt><SPAN>"http://www.w3.org/TR/html4/loose.dtd" </SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span><span>   </span></span></li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span>Calling page example</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>title</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>head</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>a</SPAN></FONT></STRONG><SPAN> </SPAN><SPAN class=attribute><FONT color=#ff0000>href</FONT></SPAN><SPAN>=</SPAN><SPAN class=attribute-value><FONT color=#0000ff>"action.php"</FONT></SPAN><SPAN class=tag><STRONG><FONT color=#006699>></span></font></strong><span>Click here!</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>a</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="">
<span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>body</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
<li class="alt">
<span></span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>html</SPAN><SPAN class=tag>></span></font></strong><span>   </span>
</li>
</ol>
Copy after login

When the user clicks the above link, the PHP function header() calls action.php. The following is the source code of action.php:

<ol class="dp-xml"><li class="alt">
<span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN>   </SPAN></SPAN><LI class=""><SPAN>// 数据库功能   </SPAN><LI class=alt><SPAN> </SPAN><LI class=""><SPAN>// 重定向   </SPAN><LI class=alt><SPAN>header("Location: $HTTP_REFERER");   </SPAN><LI class=""><SPAN>exit;   </SPAN><LI class=alt><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span>   </span>
</li></ol>
Copy after login

There are two common mistakes that need to be reminded:

After calling the PHP function header(), you must include an exit statement to stop the script, otherwise subsequent scripts may be sent before the header is sent. output.

A common error in the header() function is:

Warning: Cannot add header information - headers already sent...

PHP function header() can only be used in HTML Output is called before, so you need to check for possible empty lines, spaces, etc. in front of php.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446369.htmlTechArticleThe specific content we will explain to you today is how to use it. The following is a script called calling.php: !DOCTYPEHTMLPUBLIC " -//W3C//DTDHTML4.0Transitional//EN" "http://www.w3.org/...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template