php输出语句print printf echo sprintf比较

2026-04-01 11:51:13

1、<?php

         echo "Some dynamic output here";

    ?>

    Some static output here

  <?php

 销斤   echo "I love the summertime.";

  ?>

  echo语句是语言结构。

2、  <?php

      print("I love the summertime.");

  ?>

  <?php

        $season="summertime";

      print("级海八I love the $season.");

  ?>

print()有返回值。王扯

3、   printf("Bar inventory: %d bottles of tonic water.",100);

 //  传入二个参数:

  printf("%d bottles of tonic water cost $%f",100,43.20);

用来格式化数据。

4、 $cost=sprintf("$%.2f",43.2);

不会在浏览器显示。

猜你喜欢