php实战手册(2)

发布时间 2023-08-07 23:09:23作者: 水宝石

目录

变量

  • 定义
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>php demo</title>
  </head>
  <body>
	  <?php $x=11; ?>
	  <p>
	  php hello,world
	  </p>
	   <?php 
	   //我是注释行
	   echo $x*$x; 
	   /*
	   注释行1
	   注释行2
	    */
	    ?>
  </body>
</html>

image

  • 变量内插与null
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>php demo</title>
  </head>
  <body>
	  <p>
	  php hello,world
	  </p>
	   <?php 
	   //我是注释行
	   $x=null;
	   if (is_null($x)){ 
			echo '$x is null';
			$x=22;
		}
		?>
		<br/>
		<?php
		if ($x>11)
			echo "$x >11";
		else
		    echo $x*$x;
	    ?>
  </body>
</html>

image