Page MenuHomePhorge

function jsprintf($pattern)
libphutil Technical Documentation ()

Format a Javascript string, using JSON to export complex values. This function behaves like sprintf, except that all the normal conversions (like "%s") will be properly escaped, and additional conversions are supported:

%O (Object)
  Converts the argument to a JSON object.

%A (Array)
  Converts the argument to a JSON array.

%b (Boolean)
  Converts a value to either `true' or `false'.

%# (FBID)
  JavaScript has issues with 64-bit numbers so we use this as our
  transport mechanism from PHP to JavaScript

%J (Javascript)
  Inserts raw, unescaped Javascript. This is DANGEROUS because it WILL
  NOT BE ESCAPED.
Parameters
$pattern
Return
wild