Home >php教程 >php手册 >php数组提示Notice: Undefined offset解决办法

php数组提示Notice: Undefined offset解决办法

WBOY
WBOYOriginal
2016-06-13 09:57:081276browse

我们在使用数组时经常会碰到数组不存在了,导致我们珍array[100]这样时出现Notice: Undefined offset错误,下面我来给大家介绍如何解决这种问题

例:

 代码如下 复制代码

$array[1] ='www.bKjia.c0m';

echo $array[0] ;

输入结果是

Notice: Undefined offset: 1 in D:wwwrootwraskseo404.php on line 5 下面我们来看解决办法

解决这个问题很简单如

 代码如下 复制代码

echo isset($array[0])?$array[0]:'数组未定义';

这样就很好的解决这个问题了。

Statement:
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