Table of Contents
PHP出错界面详细说明,php出错详细说明
php跳转页面的问题
php页面使用框架问题
Home php教程 php手册 PHP出错界面详细说明,php出错详细说明

PHP出错界面详细说明,php出错详细说明

Jun 13, 2016 am 09:29 AM
php

PHP出错界面详细说明,php出错详细说明

在web 上所有常见的错误之一就是无效的链接。一旦从其它站点上出现了无效的链接,你会重新安排你 
的站点。人们会将他们喜欢的站点存成书签,如果在三个月后再次访问时,仅仅发现的是'404 Not Fount ' 
时,将不会给他们任务帮助,告诉他们如何从你的站点去查找原始的信息。让我们解决这个问题,或者至少 
给你的用户一个友好的帮助,一旦他们遇到'a 404' 错误时,能够得到一些痕迹。你可以创建普通的页面来 
报告在处理你的页面时所遇到的所有的错误。 

PHP 与Apache一起可以很自由地让你创建自已的出错页面,但是需要重新进行配置,并且要编少量的代 
码。先让我们学习配置部分。 

Apache的ErrorDocument指示用来指出在出现错误时Apache应重定向到哪一个文档(或URI)。它允许你 
为每一个你的用户可能遇到的错误代码指定一个资源。通过在你的服务器配置中增加一个ErrorDocument 404 
/error.php指示。这个将在用户访问一个不存在的页面时,重定向到'error.php'中,下面我们就会写出 
'error.php'页面。不要忘了重新启动Apache以使改动生效。 

接着,我们写出一个简单的error.php: 

你所请求的文件 (=$REDIRECT_URL?> ) 在这个服务器上不存在。 
请查找你想要的文件从 前页。 

现在试着读取一个在你服务器上不存在的页面,怎么样,你可以看到error.php了,它有着一个良好和 
友好的消息,并且还有一个到前页的链接。 

让我们把它扩展一下。正如你所见,我在error.php中使用了REDIRECT_URL变量。这个变量是Apache在 
执行了一个ErrorDocument指示时所设置的,并且给出了一种可能来找到原始的资源。在这种情况下,Apache 
还设置了一些别的变量,所有的变量可以在这里找到。使用这些变量可能创建一个很好的出错页面,用于给 
用户一个不错与友好的出错页面,而代替Apache给出的缺省页面。 

从PHP页面中输出错误 
从一个PHP页面输出错误与模拟Apache对ErrorDocument指示所做的很象,你只要简单地将用户重定向, 
通过使用query-string变量,而Apache则通常是设置在环境变量里面。这样就可以使用同一个出错页面来处 
理各种错误。下面是一个例子: 




function throw_error($message) { 
$error_page = "/err/error.php"; 

$error_url = $error_page; 
$error_url .= "?REDIRECT_ERROR_NOTES=$message"; 
$error_url .= "&REDIRECT_URL=" . $GLOBALS["PHP_SELF"]; 
$error_url .= "&REDIRECT_REQUEST_METHOD=$REQUEST_METHOD"; 
$error_url .= "&REDIRECT_STATUS=501"; 
Header("Status: 501"); 
Header("Location: $error_url"); 
exit; 


ob_start(); 
// 使用输出缓冲以便在这页中的任何地方输出错误 

if(!condition) { 
throw_error("the condition failed"); 


ob_end_flush(); 
// 页面处理完毕,刷新输出缓冲 
?>
使用PHP4的输出缓冲特性对生成一般的出错报告功能也会有帮助。但是在你确认整个出错页面处理完毕 
时,不要忘记刷新缓冲区,你可以在你的代码中的任可地方通过Header调用来进行重定向。

 

详细说明:http://php.662p.com/thread-333-1-1.html

php跳转页面的问题

a.php(注册页面)

b.php(处理页面,末尾是两种跳转方法)

代码在这儿(删去不必要的可以测试一下)
a.php

test<form action="b.php" name="myform" method="post"> 姓名:<input type="text" value="Geek信条" name="name"> <br> 性别:<input type="text" value="男" name="sex"> <br> 年龄:<input type="text" value="30" name="age"> <br> 地址:<input type="text" value="weibo.com/512656752" name="address"> <br><input type="submit" value="提交">b.php<br><?php $data['name'] = $_POST['name']; $data['sex'] = $_POST['sex']; $data['age'] = $_POST['age']; $data['address'] = $_POST['address']; // 输出查看你提交上来的信息 print_r($data); // 处理提交上来的信息 function check_name(){ // 处理方法 } function check_sex(){ } . . . // 等等的处理提交上来的数据的方法,处理完后,跳转页面 // 利用HTTP头信息重定向 $url = 'a.php'; Header("Location:".$url); // JS跳转 echo "<script>location......余下全文>><br> <br>   <p class="header2"><span class="icon i-relatedanswer"><h3 id="php页面使用框架问题">php页面使用框架问题</h3></span></p> <p class="best-replyer"></p> <p class="ft p1">当父页面刷新后,页面上的 每个元素都会重新载入,包括父页面上的 iframe元素,那么自然 iframe的内嵌页面也会重新载入刷新了,因为iframe的src属性会重新载入一次。<br>其实你可以使用 ajax来定时更新 父页面上的 一些特定信息,父页面的iframe不要更新,而iframe的src不变,那么子页面就不刷新了。<br>  </p> </form>
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles