早些時間因爲想通過pecl安裝event插件, 於是乎發生了這樣的場景:
user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Config.php on line 2095 user1@some-instances:~# vim /usr/share/php/PEAR/Config.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Registry.php on line 1190 user1@some-instances:~# vim /usr/share/php/PEAR/Registry.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Registry.php on line 1241 user1@some-instances:~# vim /usr/share/php/PEAR/Registry.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Registry.php on line 1265 user1@some-instances:~# vim /usr/share/php/PEAR/Registry.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Registry.php on line 2207 user1@some-instances:~# vim /usr/share/php/PEAR/Registry.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/DependencyDB.php on line 177 user1@some-instances:~# vim /usr/share/php/PEAR/DependencyDB.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/PEAR/Installer/Role.php on line 240 user1@some-instances:~# vim /usr/share/php/PEAR/Installer/Role.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/System.php on line 268 user1@some-instances:~# vim /usr/share/php/System.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/Console/Getopt.php on line 129 user1@some-instances:~# vim /usr/share/php/Console/Getopt.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/Console/Getopt.php on line 144 user1@some-instances:~# vim /usr/share/php/Console/Getopt.php user1@some-instances:~# pecl install event Fatal error: Array and string offset access syntax with curly braces is no longer supported in /usr/share/php/Console/Getopt.php on line 147 user1@some-instances:~# vim /usr/share/php/Console/Getopt.php user1@some-instances:~# pecl install event
當時我就矇了, 我在干什麽? 我一個勁兒的vim那些老的php程序, 到底想干嘛? 堂堂一個php7.4的環境怎麽報這麽多錯誤? 後來回憶了一波history, 發現自己不小心用系統自帶安裝包管理工具安裝過php-pear, 果斷卸載。
之後就提示找不到pecl命令了, 巡視了一番, 看樣子原來環境下的php沒被破壞, 運行以下命令來解決
ln -s /usr/local/php/bin/pecl /usr/bin/pecl
這個時候再運行
pecl install event
解決問題
Fatal error: Array and string offset access syntax with curly braces is no longer supported
這個錯誤不算大事, 純粹一個官方糾結語法所帶來的問題, 把尖括號{改爲方括號即可[