首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

“调用成员函数store() on null”Laravel如何修复

在Laravel中,当出现错误消息“调用成员函数store() on null”时,通常是因为尝试在一个空对象上调用store()函数。这种错误通常发生在尝试在一个未初始化或未定义的变量上调用函数时。

要修复这个问题,可以按照以下步骤进行操作:

  1. 检查代码中的变量初始化:确保在调用store()函数之前,相关的变量已经被正确地初始化。如果变量没有被初始化,可以使用适当的方法进行初始化,例如使用new关键字创建一个新的对象。
  2. 检查变量赋值:确保在调用store()函数之前,相关的变量已经被正确地赋值。如果变量没有被赋值,可以通过检查代码逻辑或者使用条件语句来确保变量被正确地赋值。
  3. 检查变量是否为空:在调用store()函数之前,使用条件语句或者null检查来确保变量不为空。如果变量为空,可以使用条件语句来处理这种情况,或者在变量为空时避免调用store()函数。
  4. 检查函数定义:确保store()函数已经正确地定义和实现。如果函数没有正确地定义或者实现,可以检查函数的命名、参数和返回值是否正确,并进行相应的修复。

总之,修复“调用成员函数store() on null”错误的关键是确保相关的变量被正确地初始化、赋值和检查,并确保调用的函数已经正确地定义和实现。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

Resources和AssetManager创建过程

到这里AssetManager创建完毕。然后设置相关的路径 AssetManager assets = new AssetManager(); // resDir can be null if the 'android' package is creating a new Resources object. // This is fine, since each AssetManager automatically loads the 'android' package // already. if (resDir != null) { if (assets.addAssetPath(resDir) == 0) { return null; } } if (splitResDirs != null) { for (String splitResDir : splitResDirs) { if (assets.addAssetPath(splitResDir) == 0) { return null; } } } if (overlayDirs != null) { for (String idmapPath : overlayDirs) { assets.addOverlayPath(idmapPath); } } if (libDirs != null) { for (String libDir : libDirs) { if (libDir.endsWith(".apk")) { // Avoid opening files we know do not have resources, // like code-only .jar files. if (assets.addAssetPath(libDir) == 0) { Log.w(TAG, "Asset path '" + libDir + "' does not exist or contains no resources."); } } } } 接着就创建Resource对象 r = new Resources(assets, dm, config, compatInfo); 这里看到AssetManager保存到了Resources对象中。接着进入到Resources的构造方法中 public Resources(AssetManager assets, DisplayMetrics metrics, Configuration config, CompatibilityInfo compatInfo) { mAssets = assets; mMetrics.setToDefaults(); if (compatInfo != null) { mCompatibilityInfo = compatInfo; } updateConfiguration(config, metrics); assets.ensureStringBlocks(); } 最后进入到updateConfiguration(Configuration config, DisplayMetrics metrics, CompatibilityInfo compat) mAssets.setConfiguration(mConfiguration.mcc, mConfiguration.mnc, locale, mConfiguration.orientation, mConfiguration.touchscreen, mConfiguration.densityDpi, mConfiguration.keyboard, keyboardHidden, mConfiguration.navigation, width, height, mConfiguration.smallestScreenWidthDp, mConfiguration.screenWidthDp, mConfiguration.screenHeightDp, mConfiguration.screenLayout, mConfiguration.uiMode, Build.VERSION.RESOURCES

05

如何优雅的传递 stl 容器作为函数参数来实现元素插入和遍历?

开始正文之前,做一些背景铺垫,方便读者了解我的工程需求。我的项目是一个客户端消息分发中心,在连接上消息后台后,后台会不定时的给我推送一些消息,我再将它们转发给本机的其它桌面产品去做显示。后台为了保证消息一定可以推到客户端,它采取了一种重复推送的策略,也就是说,每次当我重新连接上后台时,后台会把一段时间内的消息都推给我、而不论这些消息之前是否已经推送过,如果我不加处理的直接推给产品,可能造成同一个消息重复展示多次的问题。为此,我在接收到消息后,会将它们保存在进程中的一个容器中,当有新消息到达时,会先在这个容器里检查有没有收到这条消息,如果有,就不再转发。

02
领券