Blogger Information
Blog 17
fans 1
comment 0
visits 14580
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP基础:数据类型的演示
zl的php学习博客
Original
589 people have browsed it

1. 2.php程序的运行原理:

  1. ①浏览器访问web服务器,如果web服务器接受的是html,则返回给浏览器htmlcssjs和其他资源;如果接受的是php,那么web服务器就会找到对应的服务器处理程序处理(这里是php),并且如果需要访问数据库的话,再访问数据库,最后把处理好的数据资源(htmlcssjs和其他资源)返回给web服务器,再通过web服务器返回给浏览器进行显示。

2. 3.将php与html混编的方式与短标签的使用&&4.将常用的数据类型,全部实例演示,

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>0125作业练习:3.将php与html混编的方式与短标签的使用&&4.将常用的数据类型,全部实例演示, </title>
  7. </head>
  8. <body>
  9. <p>php使用</p>
  10. <?php
  11. echo 'Hello World';
  12. echo '<h1>Hello World</h1>';
  13. print '<h1>Hello World</h1>';
  14. printf('<h1>%s %s</h1>', 'Hello', 'World');
  15. vprintf('<h1>%s %s</h1>', ['Hello', 'World']);
  16. $den = sprintf('<h1 style="color:red;">%s %s</h1>', 'Hello', 'World');
  17. ?>
  18. <?= $den ?>
  19. <hr />
  20. <h1>基本类型+复用类型</h1>
  21. <?php
  22. $num = 1; // int
  23. $num1 = 1.1; // float
  24. $bool = true; // bool
  25. $str = 'adad'; // string
  26. $arr = [1, 2, '212']; // 数组
  27. $arr1 = ['1' => 1, '2' => 2, '212' => '212']; // 关联数组
  28. echo var_dump($num) . ' <br/>';
  29. echo var_dump($num1) . ' <br/>';
  30. echo var_dump($bool) . ' <br/>';
  31. echo var_dump($str) . ' <br/>';
  32. echo var_dump($arr) . ' <br/>';
  33. echo var_dump($arr1) . ' <br/>';
  34. echo print_r($arr) . ' <br/>';
  35. echo print_r($arr1) . ' <br/>';
  36. ?>
  37. <hr />
  38. <h1>对象</h1>
  39. <?php
  40. function testFunc(int $a, float $b): string {
  41. return 'Hello, function! a + b = ' . ($a + $b);
  42. }
  43. echo testFunc(99, 10.1) . '<br/>';
  44. class TestFunc {
  45. private $a = 0;
  46. private $b = 0;
  47. public function setA($seta) {
  48. $this->a = $seta;
  49. }
  50. public function setB($setb) {
  51. $this->b = $setb;
  52. }
  53. public function getAB() {
  54. return 'a + b = ' . ($this->a + $this->b);
  55. }
  56. }
  57. $tf = new TestFunc();
  58. echo $tf->getAB() . '<br/>';
  59. $tf->setA(1000);
  60. $tf->setB(8999.9);
  61. echo $tf->getAB() . '<br/>';
  62. ?>
  63. </body>
  64. </html>
Correcting teacher:天蓬老师天蓬老师

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