Pchp.Library.Variables.print_r C# (CSharp) Method

print_r() public static method

Outputs or returns human-readable information about a variable.
public static print_r ( Context ctx, PhpValue value, bool returnString = false ) : PhpValue
ctx Pchp.Core.Context Current runtime context.
value Pchp.Core.PhpValue The variable.
returnString bool Whether to return a string representation.
return Pchp.Core.PhpValue
        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;
            }
        }