开发者

Php gettext extension works on my local host but its not working on my hosting

I tried php gettext in my localhost and everything worked, but when I uploaded the files to my hosting it said the following:

Warning: putenv(): Safe Mode warning: Cannot set environment variable 'LC_ALL' - it's not in the allowed list in /www/zxq.net/w/e/e/weedcl/htdocs/localization.php on l开发者_如何学Pythonine 4 Fatal error: Call to undefined function bindtextdomain() in /www/zxq.net/w/e/e/weedcl/htdocs/localization.php on line 6

I'm using the free hosting service Zymic (Does it have to do with the fact that its FREE?).

My localization.php:

<?php
$locale = "de_DE";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("messages", "./locale");
bind_textdomain_codeset("messages", 'UTF-8');
textdomain("messages");
?>


The first problem is the warning message you are getting, which indicates that safe_mode is enabled -- which is too often the case when you are on some shared hosting service.

And when safe_mode is enabled, you cannot set any kind of environment variables : the only one you can set, using putenv, are the ones which have a name that starts by something listed in safe_mode_allowed_env_vars.


LC_ is probably not an allowed prefix ; which means you cannot do this :

putenv("LC_ALL=$locale");

This line being useless, you might want to remove it -- that'll at least make the warning go away...


After that, you have a second problem : the function bindtextdomain doesn't exist -- hence the Fatal Error that ends your script.

That function being one of those provided by the gettext extension, I would say that this extension is not installed / enabled on your hosting service...

You can check that running a page that contains :

<?php
phpinfo();
?>

It'll list all extensions that are installed / enabled ; if gettext is not one of those, there is not much you can do, unfortunately...

Contacting your histing provider so they install that extension would be an idea... But with a free hosting service, I doubt it'll help... You'll probably have to go with another hosting service (even if it costs a few dollars/euros... )


I'm using the free hosting service Zymic (Does it have to do with the fact that its FREE?).

Probably. It has safe_mode enabled and you can't change the LC_ALL environment variable. You will run into these kind of problems on every host that has safe_mode enabled, and most free ones have it that way.

Try to remove the putenv() call and see what happens then.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜