Blogger Information
Blog 34
fans 0
comment 0
visits 20520
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php变量常量的基本定义与使用
小庄
Original
425 people have browsed it

php变量常量的基本定义与使用

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>php test</title>
  8. </head>
  9. <body>
  10. <?php
  11. /**
  12. * php的变量类型:整型,浮点型,字符窜,布尔,数组,对象,资源(resource),null,
  13. *
  14. */
  15. //变量类型的转换(临时转换)
  16. echo '临时转换<br />';
  17. $number = 12;
  18. var_dump($number);//输出int类型值为12
  19. var_dump((string)$number);//输出string类型,值为"12"
  20. // 注意以上方式都只能对number临时转换,
  21. // 若要达到彻底永久转换,需使用php系统函数settype()
  22. echo '<hr />';
  23. echo '永久转换<br />';
  24. //变量类型的转换(永久转换)
  25. var_dump("settype返回类型:",@settype($number,'string'));//settype() 函数返回值为bool类型
  26. echo '<br />';
  27. var_dump("settype永久转换:",$number);//再次输出number变量的类型为string
  28. echo '<hr />';
  29. // php的常量
  30. echo 'php的常量<br />';
  31. define('PI','3.141533333333');
  32. const PIS = 3.1415133333;
  33. var_dump("define定义的常量:",PI);
  34. echo '<br />';
  35. var_dump("const定义的常量:",PIS);
  36. ?>
  37. </body>
  38. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!