2016-09-10 78 views
-2

我只是將laravel 5.1升級到5.2。除了我的播種機以外,一切都很順利解析錯誤:升級到laravel後數字文字無效5.2

當我運行播種機,我發現這個錯誤:

[email protected]:/var/www/sys_pb$ php artisan db:seed 


    [Symfony\Component\Debug\Exception\FatalThrowableError] 
    Parse error: Invalid numeric literal      

我無法找到谷歌搜索上的錯誤後的溶液。請給我一個相關的建議。感謝

+0

你試過'composer dump-autoload'嗎? – follio

+0

您能否提供完整的例外回溯跟蹤以及相關代碼? – Sherif

+0

@Follio,我也試過。但沒有運氣 – indi60

回答

2

From the PHP 7 Migration Guide in the Manual

Invalid Octal Literals

Previously, octal literals that contained invalid numbers were silently truncated (0128 was taken as 012). Now, an invalid octal literal will cause a parse error.

Changes to integer handling

因此,這意味着這樣的事情在你的代碼PHP 7可引起致命解析錯誤與Invalid numeric literal而以前在PHP 5中它會被忽略。

$arr = [08, 09, 10, 11]; // works in PHP 5, throws fatal error in PHP 7 

this 3v4l爲例。

+0

我試着評論所有與數據播種機相關的功能。但它仍然會出現相同的錯誤。我該如何解決問題?它與symfony有關嗎? – indi60

+0

如果它是'Throwable'類型,那麼很可能是它來自PHP。 PHP 7中的這個特定的異常是關於在你的php代碼中使用無效的數字文字。請參閱答案中的示例。 – Sherif

+0

該解決方案適用於剛剛啓動的項目,換句話說,當項目很小時,可以更改它。但是當源代碼複雜時,可能需要很長時間才能維護或至少逐個檢查。 – indi60

1

我有同樣的錯誤「分析錯誤:無效的數字文字」。對我而言,它只在數字中使用單引號。 像這樣: $ arr = ['08','09','10','11']