php/demo/demo_std.php · 1138 字节 · 下载原文
<?php
// demo_std.php —— PHP 第一层:**标准输出**(std)
// demo_std.php -- PHP layer 1: **standard output** (std)
//
// 只用 echo 与 for 循环,不碰 Crt / BGI / 宿主 ui_*。
// Only echo and a for loop; no Crt / BGI / host ui_*.
//
// 跑法(桌面 vmlcli):
// How to run (desktop vmlcli):
// dotnet scripts/vmlcli/bin/Release/net10.0/vmlcli.dll Examples/php/demo/demo_std.php
//
// 本前端的两个事实:
// Two facts about this frontend:
// ① echo 的多个实参按顺序连着打(不加空格)。
// ① echo prints its arguments in order, with no separators.
// ② 字符串里可以直接写换行(本子集不解释 \n 转义,与其他 PHP 例程一致)。
// ② a literal newline inside a string works (this subset does not interpret \n escapes; same as the other PHP samples).
echo "=== PHP 标准输出 demo ===
";
echo "=== PHP standard output demo ===
";
echo "你好,世界 / hello, world
";
echo "整数: ", 42, "
";
echo "计算: 7 * 6 = ", 7 * 6, "
";
$sum = 0;
for ($i = 1; $i <= 10; $i++) {
$sum = $sum + $i;
}
echo "循环求和: 1..10 = ", $sum, "
";