Blogger Information
Blog 94
fans 0
comment 0
visits 92655
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
【PHP】四个数据格式化函数
可乐随笔
Original
1329 people have browsed it
  1. <?php
  2. /**
  3. * 四个数据格式化函数记忆方式
  4. * 1.printf(format,a,b,...):打印(离散参数)
  5. * 2.vprintf(format,array):打印(数组参数)
  6. * 3.sprintf(format,a,b,...):只返回不打印
  7. * 4.vsprintf(format,array):只返回不打印
  8. *
  9. * 记忆:
  10. * s: 只返回不打印
  11. * v: 数组参数
  12. */
  13. // echo:无返回输出
  14. // echo 'hello';
  15. // echo print 有返回值
  16. // echo print('hello');
  17. // var_dump() 输出数组对象
  18. // var_dump([1,2,3]);
  19. // var_export([1,2,3]) 输出源代码
  20. // var_export([1,2,3]);
  21. // printf('name=%s','老马') 模板化输出;
  22. // printf('name=%s','老马');
  23. // printf('<div style="color:red">%s</div>','老马');
  24. // sprintf结果缓存
  25. // $str = sprintf('<div style="color:red">%s</div>','老马');
  26. // echo $str;
  27. // print_r() 格式化输出
  28. // $str = print_r('老马',true);
  29. // echo $str;
  30. // vprintf() //多值输出
  31. // vprintf('%d + %d = %d', [10, 20, 10 + 20]);
  32. $str = vsprintf('%d + %d = %d', [10, 20, 10 + 20]);
  33. echo $str;
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post