简体   繁体   中英

PHP function name conflict

We have a PHP-based website that has been in operation since 2005. We have just added a new developer. We have each developer install a local apache stack for debugging. When he executes the site on his workstation, there is an error message having to do with a name conflict with one function.

Specifically, we have a function called GetText which takes 5 parameters. On his system he gets a message saying the the function cannoot be redeclared. It is conflicting with a function which appears to be named gettext (note the different in capitalization) which is said to take one variable.

We do not get this conflict on any of our other instances. The other instances include our production website and three development websites. All of these instances are running on FreeBSD unix. We have developers running os OS X and in various Windows machines. The developer in question is running on Windows 7.

We do not see any such "gettext" function in our code base, including Pear libraries. As a temporary workaround we have renamed our function to "XGetText". That cures the problem.

Where is this conflict coming from?

That developer has the gettext extension active on his PHP install, which defines the function gettext . Capitalisation doesn't matter to PHP. He'll either have to deactivate the extension in his php.ini if possible, or recompile PHP to exclude the gettext extension (in which case I'd suggest using a virtual machine to install a custom PHP version).

BTW, gettext is a pretty popular and often used extension, naming your userland function GetText is a bad choice.

PHP has a built-in gettext function (in both PHP 4 and PHP 5), and PHP function names are case insensitive. Presumably, your PHP is not compiled with the --with-gettext flag and his is.

Disable the Gettext extension , as I'm sure you're not going to use it in your project

This is how it's done in WAMP:

在此处输入图片说明

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