今天是第9次学习,代码:
实例
<?php header('content-type:text/html;charset=utf-8'); echo '<h3>变量的类型与检测作业20180822</h3>'; $age=30; $salary=3560.99; $name='peter zhu'; $isMarried=true; echo $name,'的<span style="color:red">年龄</span>是:',$age,',工资是:',$salary,',是否已婚:',$isMarried.'<hr>'; $books=['php','mysql','html','css','javascript']; echo'<pre>'; print_r($books); $student=new stdClass(); $student->name='王伍'; $student->course='php'; $student->grade=80; var_dump($student); var_dump($student->name); echo $student->name,'<br>','<hr>'; echo'<h3 style="color:blue">',print_r($student->name,true),'</h3>','<hr>'; $file=fopen('test.txt','r') or die('打开失败'); echo fread($file,filesize('test.txt')); //fclose($file); $price=null; echo '$price is' . $price; echo'<br>'; echo is_null($price)?'是NULL':'不是NULL','<br>'; echo gettype($file),'<hr>'; $price=125.99; settype($price,'integer'); echo $price,'<hr>'; echo gettype($price);
运行实例 »
点击 "运行实例" 按钮查看在线实例
代码2:
实例
<?php header('content-type:text/html;charset=utf-8'); echo '<h3>分支结构20180822</h3>'; $grade=85; if($grade<60){ echo'<p style="color:red">很不幸,您得补考</p>'; }else if ($grade>=60&&$grade<80){ echo'<p style="color:green">考得还不错</p>'; }else if ($grade>=80&&$grade<=100){ echo '<p style="color:green">真是个天才</p>'; }
运行实例 »
点击 "运行实例" 按钮查看在线实例