简体   繁体   中英

PHP update from 5.2.x to 5.3.14 caused a Locale issue

Our server recently had an update done (PHP was updated from 5.2.x to 5.3.14) Because of this update we cannot use our custom Locale class that is being run by __autoload() From my understanding this is caused by a Locale class existing some where in the "PEAR"

Is there a way for me to resolve this conflict issue without changing my class name from Locale to something else (basically some how force the PEAR locale not to load or ignore it just for the Locale request)?

Thanks

Since Locale is now a native PHP class, you can't override it directly, which is why your code no longer works.

Solutions:

  1. Rebuild you copy of PHP so it doesn't include the Locale module. Probably not a good idea, and definitely bad for compatiblity, but could be considered if you're desperate.

  2. Rename your class. There are refactoring tools that can make this sort of thing fairly easy.

  3. Use PHP 5.3's namespace feature to give your Locale class a different namespace to the built-in Locale class. Add a namespace clause to the top of your class file, and use your namespace wherever you want to reference your Locale class rather than the built-in one.

The choice between 2 and 3 is up to you. I'd suggest 2, since your class probably isn't functionally similar to the PHP one, so you'll want to distance yourself from it. But the namespace solution is also an option if you want to keep your current classname.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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