6

PHP 7 introduced Unicode Codepoint Escape Syntax which is very easy to use, but I can't get it to work with a variable as a codepoint.

echo "\u{1f602}"; // echoes 

$em = "1f602";
echo sprintf("\u{%x}", $em); // returns error "Invalid UTF-8 codepoint escape sequence"

What am I doing wrong ?

crtn-hrd
  • 161
  • 4
  • 1
    String escapes really just work as code literals, not in combination with interpolation. – mario Sep 24 '18 at 14:36

0 Answers0