[英]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
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.