PHP 语法入门
2020-04-21  本文已影响0人 
887d1fc86fe6
- 
HelloWorld
 
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* css */
  </style>
  <script>
    // js
  </script>
</head>
<body>
  <?php 
    echo 'hello world';
  ?>
</body>
</html>
- demo 效果:
 
- 
phpinfo()
查看php信息
 
<?php
  phpinfo();
?>
- 
PHP标记形式
PHP语言,是一种可以嵌入到“htm1"代码中的后台处理语言(程序)
有以下几种标记形式,只推荐第- -种。- 1、<?php php代码写在这里... ?> 推荐写法!
 - 2、<?php php代码写在这里... 纯PHP代码可以省略标记结尾符
 - 3、<script language= "php"> php 代码写在这里... </script>
 - 4、<? php代码写在这里... ?>
需要到php. ini中进行配置: short_open_tag = On
默认为Off, 表示不能用该形式。 
 
; This directive determines whether or not PHP will recognize code between
; <? and ?> tags as PHP source which should be processed as such. It is
; generally recommended that <?php and ?> should be used and that this feature
; should be disabled, as enabling it may result in issues when generating XML
; documents, however this remains supported for backward compatibility reasons.
; Note that this directive does not control the <?= shorthand tag, which can be
; used regardless of this directive.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/short-open-tag
short_open_tag = Off
- PHP语法结束符
使用英文分号 ";" 表示一条语句的结束。