PHP问题 —— Notice: Undefined index:

简介:

1.1  Notice: Undefined index: login in

1.1.1  现象

访问网页,出现如下错误信息:

( ! ) Notice: Undefined index: login in D:\ProjectWork\SourceCode\Server\osFileManager\index.php on line 59

Call Stack

# Time   Memory Function   Location

1 1.0141 919464 {main}( )  ..\index.php:0

1.1.2  原因

出错的行代码为:

if ($_REQUEST['login']) $user = $_REQUEST['login'];

根据错误信息,应该是$_REQUEST[]这个数组中,没有下标为login的元素,但这是客户端传过来的请求,这句本意是$_REQUEST[]数组中如果有login下标,就进行后续操作。

1.1.3  解决

访问下标前先判断该下标是否存在,代码修改如下:

if (isset($_REQUEST['login'])) $user = $_REQUEST['login'];






本文转自 tywali 51CTO博客,原文链接:http://blog.51cto.com/lancelot/1772962,如需转载请自行联系原作者
目录
相关文章
|
PHP Windows
windows下 Call to undefined function posix_getpid() in ……\Workerman\Worker.php 的解决方法
windows下 Call to undefined function posix_getpid() in ……\Workerman\Worker.php 的解决方法
129 0
windows下 Call to undefined function posix_getpid() in ……\Workerman\Worker.php 的解决方法
|
10月前
|
PHP
php模版引擎smarty出现Undefined index的解决方案
php模版引擎smarty出现Undefined index的解决方案
68 0
|
PHP
PHP使用explode报错:Undefined offset: 1
PHP使用explode报错:Undefined offset: 1
104 0
|
前端开发 应用服务中间件 PHP
PHP path_info,Thinkphp controller not exists index\php
研究过thinkphp框架源码的,或者深入了解过mvc的,都应该知道thinkphp框架的路由,是根据path_info值来解析的,甚至传参也可以带在path_info中
343 1
|
PHP
TP5.1自定义创建命令(php think make:controller app\index\User)
TP5.1自定义创建命令(php think make:controller app\index\User)
98 0
TP5.1自定义创建命令(php think make:controller app\index\User)
|
PHP
Undefined index: HTTP_REFERER 解决方法
Undefined index: HTTP_REFERER 解决方法
176 0
Undefined index: HTTP_REFERER 解决方法
|
SQL 关系型数据库 测试技术
PolarDB-X「DRDS」 全局二级索引 (Global Secondary Index, GSI) 结合业务压测记录「服务端PHP」
PolarDB-X「DRDS」 全局二级索引 (Global Secondary Index, GSI) 压测记录
PolarDB-X「DRDS」 全局二级索引 (Global Secondary Index, GSI) 结合业务压测记录「服务端PHP」
|
PHP Apache
PHP Notice: Undefined index错误提示的解决办法
 配置好后运行PHP网站,出现了一个错误提示:“PHP Notice: Undefined index ...”
2026 0
|
8月前
|
关系型数据库 MySQL PHP
PHP 原生操作 Mysql
PHP 原生操作 Mysql
82 0
|
8月前
|
关系型数据库 MySQL 数据库连接
PHP 原生连接 Mysql
PHP 原生连接 Mysql
108 0