Php storage expression character display method [regular expression conversion] in interaction with users, the front-end long text theoretically allows users to use the expression, but when the front-end uploads the expression to the background interface, due to the encoding restrictions of some data, there is no way to save such data.
The method I use here is to convert the emoticons in text using regular expressions, read them from the database, and perform a reverse regular expression.
[Note: After the emoticon is successfully escaped, it will automatically match the current emoticon in the browser]
Paste the code below
/*** Set long text content ** @ param $ content * @ return mixed */public function setContent ($ content) {return preg_replace_callback ('/[\ xf0-\ xf7]. {3}/', function ($ r) {return' @ e '. base64_encode ($ r [0]) ;}, $ content );} /*** get the processed long text content ** @ param $ content * @ return mixed */public function getContent ($ content) {return preg_replace_callback ('/@ E (. {6 }=)/', function ($ r) {return base64_decode ($ r [1]) ;}, $ content );}
Permanent Address: http://blog.it985.com/16082.html
This article is from the IT985 blog. please indicate the source and relevant links when reprinting.