开发者

How to unescape Javascript in PHP [duplicate]

开发者 https://www.devze.com 2023-03-13 11:36 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to decode Unicode escape sequences like “\\u00ed&rdquo开发者_JAVA技巧; to proper UTF-8 encoded charac
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to decode Unicode escape sequences like “\u00ed&rdquo开发者_JAVA技巧; to proper UTF-8 encoded characters?

I have some javascript text that contains values like '\u003c' (less than sign <).

Is there a php functions that allows me to unescape javascript ?

(I did not expect urldecode to work, though i tried it. It does not indeed.)


yep, would just suggest it, urldecode();

Try:

<?php
  function utf8_urldecode($str) {
    $str = preg_replace("/%u([0-9a-f]{3,4})/i","&#x\\1;",urldecode($str));
    return html_entity_decode($str,null,'UTF-8');;
  }
?>

Reference

0

精彩评论

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

关注公众号