Rao*_*oul 4 php unicode typo3 urlencode
η的URL编码是%CE%B7.但在PHP中,我写作时会得到一些奇怪的符号echo urldecode("%ce%b7");
相反,如果我写,echo urlencode("?");那么我得到%26%23951%3B.为什么我不能使用%CE%B7?
解
问题是我们使用typo3.它有些如何不使用unicode进行内部处理.一旦我们设置$TYPO3_CONF_VARS['BE']['forceCharset'] = 'utf-8';错字3输出echo urldecode("%ce%b7");是正确的.
为什么echo urlencode("?");让我%26%23951%3B看到Joni的答案.
urldecode("%ce%b7")产生以UTF-8编码的 η .如果您使用其他编码查看输出,您可能会看到其他内容.
另一方面,当你解码%26%23951%3B时,你没有获得η; 你获得的η是η的HTML实体代码.要解码实体代码,请使用html_entity_decode:
echo html_entity_decode('η', false, 'UTF-8'); // prints ?, encoded in UTF-8
Run Code Online (Sandbox Code Playgroud)