Recenty I was updating some code on my Laravel app and I managed to get it working perfectly on local, no error messages whatsoever, so I decided to upload it to the test server.
最近,我在我的Laravel应用程序上更新了一些代码,我设法让它在本地完美运行,没有任何错误消息,所以我决定将它上传到测试服务器。
When I did, this laminas-diactoros package started giving this error message:
当我这样做的时候,这个叠片变阻器包开始给出这样的错误信息:
PHP Parse error: syntax error, unexpected 'fn' (T_STRING), expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /route/to/MyProject/vendor/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.php on line 29
After some research I learned that this is because in php7.4 fn is a reserved word, so I then did composer require laminas/laminas-diactoros
to see if updating the package would make it change syntax and work allright. It wont update further than 2.17 and in that version it still uses fn. I don't know what else to see or to do. I'm using laravel 6.20.44, php 7.4 and apache2. If you need any more information just ask and I'll try to answer quick, but this is literally everything I can think of that could be failing.
经过一番研究,我了解到这是因为在php7.4中,fn是一个保留字,所以我做了composer,要求使用lamis/clamis-diactoros,看看更新包是否会改变语法并正常工作。它不会更新到2.17以上,在那个版本中它仍然使用fn。我不知道还能看什么或做什么。我使用的是laravel 6.20.44、php7.4和apache2。如果你需要更多信息,只需询问,我会尽快回答,但这确实是我所能想到的一切,可能都会失败。
更多回答
优秀答案推荐
As answered by Froschdesign in this post on Disclosure Laminas. The problem you're facing is with PHP version conflict between cli and apache2. Your command line shows PHP version 7.4 but confirm in your CPanel and in the Apache virtual host file which version is being used by Apache. Thanks!
正如Froschdesign在这篇关于Disclosure Laminas的帖子中所回答的那样。您面临的问题是cli和apache2之间的PHP版本冲突。您的命令行显示PHP 7.4版本,但在CPanel和Apache虚拟主机文件中确认Apache正在使用哪个版本。谢谢
<?php
// below information gives you the version being used by Apache.
phpinfo();
// below command tells you the version of PHP in the command line.
$ php --version
更多回答
我是一名优秀的程序员,十分优秀!