本文整理汇总了C#中Pchp.Core.Context.Echo方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Echo方法的具体用法?C# Context.Echo怎么用?C# Context.Echo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pchp.Core.Context
的用法示例。
在下文中一共展示了Context.Echo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessStatus
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;
}
}
示例2: var_export
/// <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;
}
}
示例3: var_dump
/// <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]));
}
}
示例4: print_r
//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;
}
}