When I execute from console this command "sendsms XXXXXXXXX 'śćźłóśadad'" everything is OK. But when I execute it in php with exec("sendsms XXXXXXXXX 'śćźłóśadad'"); the body of msg is without polish letters. Debian console is in UTF-8, php file is in UTF-8. When I execute this php file from cli everything is OK but the problem is when I run it from browser (the same file). Why ? How to fix it ?
When you run your script via the CLI interface, the subprocess inherits its parent's environment, which contains the variable LANG
, used to pass the encoding of the bytes to the underlying C runtime.
Likely when you execute your program via mod_php, LANG
is not set. So you may succeed by configuring it yourself:
<?php
putenv('LANG=en_US.UTF-8');
exec("sendsms 888888888 cosśźćłó");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With