草庐IT

undefine

全部标签

PHP 5.6 : ArrayAccess: Function isset calls offsetGet and causes undefined index notice

我编写了实现ArrayAccess接口(interface)的简单PHP类:classMyArrayimplementsArrayAccess{public$value;publicfunction__construct($value=null){$this->value=$value;}publicfunction&offsetGet($offset){var_dump(__METHOD__);if(!isset($this->value[$offset])){thrownewException('Undefinedindex:'.$offset);}return$this->val

php - undefined offset 错误,但偏移量不是未定义的

我得到:Notice:Undefinedoffset:0但在我的代码中,我可以print_r我试图获取的元素及其明确定义。functionget_members($entries_found){$members=$entries_found[0]['member'];...}如果我print_r($members)我得到了预期的输出,但是我仍然收到通知。有什么线索吗? 最佳答案 做var_dump($entries_found);检查数组的偏移量是否确实为零。您可以尝试的其他事情是重置数组指针reset($entries_found

PHP: undefined offset 为 0,但它就在那里(我认为)

所以我有一个二维数组,由短语和单个单词组成,称为$frags,`var_dump就像这样:array(4){[0]=>array(5){[0]=>string(3)"the"[1]=>string(4)"term"[2]=>string(4)"'AI'"[3]=>string(5)"still"[4]=>string(7)"manages"}[1]=>array(2){[0]=>string(2)"to"[1]=>string(5)"creep"}[2]=>array(3){[0]=>string(4)"into"[1]=>string(2)"my"[2]=>string(6)"spe

php - 注意: undefined offset :在第641行的/my/Zend/ib/Search/Lucene/Index/SegmentInfo.php中

我在使用zendsearch-lucene框架编制索引时遇到问题。我们的文件存储库有大约25000个文件,我正试图为它们建立索引。但在批索引过程中,出现了以下错误:Notice:Undefinedoffset:2047in/my/Zend/lib/Search/Lucene/Index/SegmentInfo.phponline641Notice:Tryingtogetpropertyofnon-objectin/my/Zend/lib/Search/Lucene/Index/SegmentMerger.phponline202Fatalerror:Uncaughtexception'

PHP - 与 "Undefined offset"错误不一致

这个问题在这里已经有了答案:phparrayaccessonboolean(3个答案)关闭5年前。为什么PHP在此处抛出“注意:undefinedoffset”错误:但不是这里:

PHP: undefined offset :0,但不是 dd()

我在使用laravel时遇到了Undefinedoffset:0错误。奇怪的是,当我dd()它时,它出现了。$ports=$container->getPorts();$ports=$ports[0];这将返回Undefinedoffset:0当我dd()$ports=$container->getPorts();dd($ports[0]);Port{#336#privatePort:80#publicPort:32780#type:"tcp"}完整数组:array:1[▼0=>Port{#336▼#privatePort:80#publicPort:32780#type:"tcp"}

php - Foreach codeigniter View 上的 undefined variable 错误

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况相关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭9年前。我在我看来有这个错误,无法找出问题所在。APHPErrorwasencounteredSeverity:NoticeMessage:Undefinedvariable:cFilename:views/commentsList.phpLineNumber:10这是我的View代码$comments是来自Controller的数组。$c是循环变量,所以我不明白

php - 同一文件上的函数和类 : undefined function

这个问题在这里已经有了答案:autoloadfunctionsinphp[duplicate](5个答案)关闭9年前。根据PSR-0,我有一个包含类和函数定义的文件定义(自动加载):namespaceFoo;functionb(){};classBar{}我有那个类的测试,放在同一个命名空间中:namespaceFoo;classBarTest{}当我尝试访问测试类中的b()函数时,出现了一个undefinedfunction错误:namespaceFoo;classBarTestextendsPHPUnit_Framework_TestCase{publicfunctiontestS

javascript - Yii加载动态添加(使用ajax)GridView TypeError : settings is undefined

我使用ajax并动态加载内容到GridView。它工作了,但没有加载gridviewjs(jquery.yiigridview.js)和yiiGridView($options);"并且当我使用$.fn.yiiGridView时会产生错误。如果我不使用ajax所有正常工作所以,如果我使用ajax动态加载内容,我无法重新加载它。$.fn.yiiGridView.update('mygrid');错误类型错误:设置未定义$grid.addClass(settings.loadingClass)这是我的代码:索引javaScipt代码(调用Controller和加载内容):sendAjaxC

php - 为什么我在 Laravel 中收到 "Undefined variable: var"错误?

我一直在尝试传递一些数据以在我的View中可用,但在遵循了几个指南之后,我总是得到一个Undefinedvariable:var错误。我已经在2种不同的尝试中添加到app/Providers/AppServiceProvider.php:使用共享():publicfunctionboot(){//Makethiscustomglobaldataavaliabletoallviews$var="Foobar";view()->share('var',$var);}使用Composer():publicfunctionboot(){view()->composer('partials.na