Home php教程 php手册 Notice:undefined index ..错误提示解决方法

Notice:undefined index ..错误提示解决方法

May 25, 2016 pm 04:52 PM
index Error message

一,这个因为是变量未定义我们只要找到相关的位置加上如下代码:

function _get($str){  
$val = !emptyempty($_GET[$str]) ? $_GET[$str] : null;  
    return $val;  
}
Copy after login

或者我们可以这样:

isset($_GET['你的变量'])?$_GET['你的变量']:'';

上面我们只举了get的用法还有post也一样,只要把上面的get改成post.还有一种程序的全局定义方法:

if (!$cfg['debug']) { 
    error_reporting(0); 
    ob_start('ob_gzhandler'); 
} else { 
    error_reporting(E_ALL ^ E_NOTICE); 
}
Copy after login

这样我们只要对变量debug进行设置0或1对错误提示进行开关了.

其它网页提供的方法:

方法1:服务器配置修改,修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE

方法2:在出现notice代码之前加上@,@表示这行有错误或是警告不要输出,@$username=$_post['username'];

注:如果你是利用了全局定义或在修改php.ini配置文件这样所有错误提示都不会出,这样对于开发测试来讲是相当的麻烦的,建义利用程序的方法,关闭错误提示最在在服务器上设置。


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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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)

What file is index.html? What file is index.html? Feb 19, 2024 pm 01:36 PM

index.html represents the home page file of the web page and is the default page of the website. When a user visits a website, the index.html page is usually loaded first. HTML (HypertextMarkupLanguage) is a markup language used to create web pages, and index.html is also an HTML file. It contains the structure and content of a web page, as well as tags and elements used for formatting and layout. Here is an example index.html code: &lt

Solve the problem of 'only collecting some error information' in win10 Solve the problem of 'only collecting some error information' in win10 Jan 13, 2024 pm 11:24 PM

How to solve the problem "We only collect certain error information" in win10? Many users have expressed that they feel helpless. Is there really no solution? No, today I will introduce to you how to solve the problem "We only collect certain error information" in win10. I hope it will be helpful to you. With the popularity of computers, nowadays, basically every household has one or more computers. The emergence of computers has indeed brought us great convenience, but it has also brought us a lot of trouble. For example, sometimes a prompt "We only collect certain error information" appears. What is going on and what should I do? What's the solution? Today I will tell you about the solution to this problem. Method 1: Press the "win+R" key combination on the keyboard to open Run

what is mysql index what is mysql index Oct 08, 2023 am 11:47 AM

The index in MySQL means index. It is a data structure used to speed up the query of database tables. The index can be compared to the catalog of a book. It stores the values ​​​​of specific columns in the table and the corresponding row positions, making the database more efficient. Locate and access data quickly. The function of the index is to improve query efficiency. Without an index, the database needs to scan the entire table row by row to find matching data. This method will be very time-consuming in large tables. With an index, the database can The required data rows are quickly located in the order, which greatly improves the query speed.

How to solve the deadlock caused by MySQL optimization index merge How to solve the deadlock caused by MySQL optimization index merge May 27, 2023 pm 05:49 PM

A deadlock occurred in the background production environment. By checking the deadlock log, we saw that the deadlock was caused by two identical update statements (only the values ​​in the where condition were different), as follows: UPDATEtest_tableSET`status`=1WHERE`trans_id`=' xxx1'AND`status`=0;UPDATEtest_tableSET`status`=1WHERE`trans_id`='xxx2'AND`status`=0; It was confusing at first, but after a lot of querying and learning, the deadlock was analyzed

PHP source code running problem: index error solution PHP source code running problem: index error solution Mar 09, 2024 pm 09:24 PM

PHP source code running problem: Index error resolution requires specific code examples. PHP is a widely used server-side scripting language that is often used to develop dynamic websites and web applications. However, sometimes you will encounter various problems when running PHP source code, among which "index error" is a common situation. This article will introduce some common causes and solutions of index errors, and provide specific code examples to help readers better deal with such problems. Problem Description: When running a PHP program

What should I do if the Win7 application Windows System Assessment Tool prompts an error? What should I do if the Win7 application Windows System Assessment Tool prompts an error? Jul 15, 2023 am 09:45 AM

Recently, when a Win7 system user was using the system's built-in experience index evaluation tool to evaluate the system operation, the "Windows System Evaluation Tool" error occurred and the "Windows System Evaluation Tool has stopped working" error dialog box popped up, resulting in the inability to To evaluate the system, how should this be solved? The editor below will introduce to you the solution to the error message prompted by the Windows System Assessment Tool in Win7 applications. Win7 application windows system assessment tool prompts error solution 1. Press the "Win+R" keyboard shortcut to open the run window and type "%USERPROFILE%\AppData\Roaming\Microsoft\Tem

Your connection is not private - Google privacy settings error Your connection is not private - Google privacy settings error Feb 25, 2024 pm 03:42 PM

Google privacy settings error: Your connection is not private. In recent years, as concerns about personal privacy have grown, major technology giants have been working hard to improve their privacy protection measures. However, not long ago, some users discovered that there was an error in Google's privacy settings, causing their connections to no longer be private. With the popularity of the Internet, we increasingly store personal information in the cloud and conduct various communications and operations through the network. As one of the world's largest search engines, Google receives and processes large amounts of user data. In order to protect user privacy,

How to solve common problems in PHP: syntax errors and warnings How to solve common problems in PHP: syntax errors and warnings Jun 11, 2023 pm 04:13 PM

PHP is a widely used server-side programming language often used to build dynamic web pages. However, when writing PHP scripts, you often encounter various syntax errors and warnings. These errors and warnings can cause your code to not run properly or cause problems, so it's important to resolve them. This article will introduce common problems in PHP: syntax errors and warnings, and provide effective methods on how to solve these problems. Syntax Errors Syntax errors are a very common problem when writing scripts in PHP. Syntax errors may be due to the following reasons

See all articles