简体   繁体   English

在Mac OS X 10.6.6上安装pear时,PHP语法错误

[英]PHP syntax error when installing pear on mac OS X 10.6.6

I'm trying (with some problems) to install pear on my system, Mac osX 10.6.6 我正在尝试(有一些问题)在我的系统Mac osX 10.6.6上安装pear

PHP works ok, as apache and mysql. PHP可以正常运行,如Apache和mysql。

On /usr/local I followed the instructions: 在/ usr / local上,我按照说明进行操作:

$ curl http://pear.php.net/go-pear.phar

$ php go-pear.phar

and I get 我得到

PHP:  syntax error, unexpected BOOL_FALSE in /private/etc/php.ini on line 1050

I'm not sure what's wrong with my php.ini. 我不确定php.ini有什么问题。

您还可以使用:

$ php -d detect_unicode=0 go-pear.phar

I finally figured it out, so I'm posting the solution for future references. 我终于弄清楚了,因此我将发布解决方案以供将来参考。

My PHP.ini was corrupted, so I had to go back to PHP.ini.default and redo all the changes. 我的PHP.ini损坏了,所以我不得不回到PHP.ini.default并重做所有更改。

Then I changed: 然后我改变了:

phar.require_hash = Off 

as suggested in other posts, 正如其他帖子所建议的,

and finally added: 最后添加:

detect_unicode = Off 

Bingo! 答对了! From what I understand, the Zend engine Unicode checker is enabled by default on osX 10.6 and it causes a conflict when opening a .phar 据我了解,在osX 10.6上默认启用Zend引擎Unicode检查器,并且在打开.phar时会引起冲突。

Reference: http://bugs.php.net/bug.php?id=42396 参考: http : //bugs.php.net/bug.php?id=42396
Credits to matt/technosophos for posting the workaround. 感谢matt / technosophos发布解决方法。

I checked php.ini first thing when I saw the error. 看到错误时,我首先检查了php.ini。

This is what it looks like around line 1050: 这是1050行附近的样子:


[Phar]

; http://php.net/phar.readonly

; phar.readonly = On

; http://php.net/phar.require-hash

;phar.require_hash = On

;phar.cache_list =

(still scratching my head ...) (仍然抓挠我的头...)

Being new to Mac I just spent few hours trying to figure out why PEAR wasn't installing on my OSX 10.6.0 setup (Apache and PHP 5.3.3 were pre-installed without PEAR). 作为Mac的新手,我花了几个小时试图弄清楚为什么未在OSX 10.6.0安装程序上安装PEAR(Apache和PHP 5.3.3预先安装而没有PEAR)。 Trying to follow the usual instructions: 尝试遵循通常的说明:

$ wget http://pear.php.net/go-pear.phar
$ sudo php go-pear.phar

... would just result in a string of question marks ('??????'), and no further error messages even though I had enabled display all errors. ...只会产生一串问号('??????'),即使我启用了显示所有错误,也不会再显示任何错误消息。

In the end the problem was solved by reinstalling PHP5 from macports (the current version is 5.3.5). 最后,通过从macports重新安装PHP5(当前版本为5.3.5)解决了该问题。 Once I had done that, 'sudo php go-pear.phar' worked without any problems. 一旦完成,“ sudo php go-pear.phar”就可以正常工作了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM