Echo() public method

public Echo ( PhpNumber value ) : void
value PhpNumber
return void
Example #1
0
        static int ProcessStatus(Context ctx, PhpValue status)
        {
            switch (status.TypeCode)
            {
                case PhpTypeCode.Alias:
                    return ProcessStatus(ctx, status.Alias.Value);

                case PhpTypeCode.Long:
                    return (int)status.ToLong();

                default:
                    ctx?.Echo(status);
                    return 0;
            }
        }
Example #2
0
        int ProcessStatus(Context ctx, ref PhpValue status)
        {
            switch (status.TypeCode)
            {
                case PhpTypeCode.Alias:
                    return ProcessStatus(ctx, ref status.Alias.Value);

                case PhpTypeCode.Long:
                case PhpTypeCode.Int32:
                    return (int)status.ToLong();

                default:
                    if (ctx != null)
                    {
                        ctx.Echo(status);
                    }
                    return 0;
            }
        }
 public override void Output(ref PhpValue me, Context ctx) => ctx.Echo(me.Array.ToStringOrThrow(ctx));
 public override void Output(ref PhpValue me, Context ctx) => ctx.Echo(Convert.ToStringOrThrow(me.Object, ctx));
 public override void Output(ref PhpValue me, Context ctx) => ctx.Echo(me.String);
 public override void Output(ref PhpValue me, Context ctx) => ctx.Echo(me.Boolean);
Example #7
0
        /// <summary>
        /// Outputs or returns a pars-able string representation of a variable.
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="variable">The variable.</param>
        /// <param name="returnString">Whether to return a string representation.</param>
        /// <returns>A string representation or a <c>null</c> reference if <paramref name="returnString"/> is <c>false</c>.</returns>
        public static string var_export(Context ctx, PhpValue variable, bool returnString = false)
        {
            var output = (new ExportFormatter(ctx, "\n")).Serialize(variable);

            if (returnString)
            {
                // output to a string:
                return output.ToString(ctx);
            }
            else
            {
                // output to script context:
                ctx.Echo(output);
                return null;
            }

        }
Example #8
0
 /// <summary>
 /// Dumps variables.
 /// </summary>
 /// <param name="ctx">Current runtime context.</param>
 /// <param name="variables">Variables to be dumped.</param>
 public static void var_dump(Context ctx, params PhpValue[] variables)
 {
     var formatter = new DumpFormatter(ctx, "\n"); // TODO: HtmlDumpFormatter
     for (int i = 0; i < variables.Length; i++)
     {
         ctx.Echo(formatter.Serialize(variables[i]));
     }
 }
Example #9
0
        //class HtmlDumpFormatter : DumpFormatter
        //{

        //}

        #endregion

        /// <summary>
        /// Outputs or returns human-readable information about a variable. 
        /// </summary>
        /// <param name="ctx">Current runtime context.</param>
        /// <param name="value">The variable.</param>
        /// <param name="returnString">Whether to return a string representation.</param>
        /// <returns>A string representation or <c>true</c> if <paramref name="returnString"/> is <c>false</c>.</returns>
        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;
            }
        }