public static PhpValue print_r(Context ctx, PhpValue value, bool returnString = false) { var output = (new PrintFormatter(ctx, "\n")).Serialize(value); if (returnString) { // output to a string: return PhpValue.Create(output); } else { // output to script context: ctx.Echo(output); return PhpValue.True; } }