dodgepudding / wechat-php-sdk

微信公众平台php开发包, weixin developer SDK.
4.44k stars 2.33k forks source link

关于wechat类文本回复的换行问题(BUG) #359

Open joyokim opened 6 years ago

joyokim commented 6 years ago
    /**
     * 过滤文字回复\r\n换行符
     * @param string $text
     * @return string|mixed
     */
    private function _auto_text_filter($text) {
        if (!$this->_text_filter) return $text;
        return str_replace("\r\n", "\n", $text);
    }

以上为实现文本消息回复的换行,其中str_replace("\r\n", "\n", $text);是无法识别到\r\n.

正确应为 return str_replace("\\r\\n", "\n", $text);

landall commented 5 years ago

人家不是那个意思,不是让你用字符写\r\n这四个字符的,只是不要用windows的换行符而已。