简体   繁体   English

Laravel 5.4 中未定义 PHP 紧凑方法

[英]PHP compact method undefined in Laravel 5.4

I'm having to move my laravel 5.4 app to a >=PHP 7.3 Server.我不得不将我的 Laravel 5.4 应用程序移至 >=PHP 7.3 服务器。 Upgrading the App to a higher laravel version breaks everything.将应用程序升级到更高的 Laravel 版本会破坏一切。 So I'm stuck with making this work as is.所以我坚持按原样完成这项工作。 The problem now is that Compact() method (which was used to pass variables to the view is undefined).现在的问题是 Compact() 方法(用于将变量传递给视图是未定义的)。 I'm considering writing a replica of the Compact method in a helper class to make it globally available.我正在考虑在辅助类中编写 Compact 方法的副本,以使其全局可用。 Now I can't even replicate the PHP compact method natively.现在我什至无法在本地复制 PHP 紧凑方法。 Please help with any suggestions.请帮助提供任何建议。 Whether on how to fix the issue or with a sample alternative code to the compact method.无论是关于如何解决问题还是使用紧凑方法的示例替代代码。

you are using an older version of laravel with new version of php.您正在使用旧版本的 laravel 和新版本的 php。

either you can change your php version to downgrade or you can move to Laravel 5.5您可以将 php 版本更改为降级,也可以移动到 Laravel 5.5

check detail here在此处查看详细信息

You should use compact() :您应该使用compact()

$name = 'James';
surname = 'Hetfield'
return view('some-template-name', compact('name', 'surname'));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未定义的变量php laravel 5.4 - undefined variable php laravel 5.4 升级到laravel 5.4后调用未定义的方法 - Call to undefined method after upgrading to laravel 5.4 laravel 5.4:PHP致命错误:调用未定义的方法Illuminate \\ Foundation \\ Application :: configure() - laravel 5.4: PHP Fatal error: Call to undefined method Illuminate\Foundation\Application::configure() Laravel 5.4中的未定义常数 - Undefined constant in Laravel 5.4 PhpRedis错误异常unset中的非法偏移类型或未定义方法share()的PHP致命错误php调用-Laravel 5.4 - PhpRedis Error Exception Illegal offset type in unset or Php fatal error php call to undefined method share() - Laravel 5.4 Laravel 5.4 Artisan Migrate失败,调用未定义的方法dispatch() - Laravel 5.4 Artisan Migrate fails with Call to undefined method dispatch() Laravel 5.4:调用未定义的方法Illuminate / Database / Query / Builder :: getRelated() - Laravel 5.4: Call to undefined method Illuminate/Database/Query/Builder::getRelated() 调用未定义的方法Illuminate \\ Database \\ Query \\ Builder :: notify()Laravel 5.4 - Call to undefined method Illuminate\Database\Query\Builder::notify() Laravel 5.4 在laravel 5.4中调用未定义的方法Illuminate \\ Database \\ Query \\ Builder :: map() - Call to undefined method Illuminate\Database\Query\Builder::map() in laravel 5.4 在Laravel 5.4中调用未定义的方法Illuminate \\ Support \\ Facades \\ Validator :: make() - Call to Undefined method Illuminate\Support\Facades\Validator::make() in Laravel 5.4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM