标签:开始 color error 错误提示 required 过滤 pat ror pst
Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required ‘D:/phpStudy/WWW/褰㈢姸鎵撳嵃.php‘ (include_path=‘.;C:\php\pear‘) in Unknown on line 0
<!DOCTYPE html> <html> <head> <title>形状打印</title> <meta http-equiv = "content-type" content="text/html; charset = utf-8 "> </head> <body> <?php $a=10;$b=10;//a,长。b,宽。 for ($y=0; $y <= $b; $y++) { //向下扫描 for ($x=0; $x <= $a; $x++) { //向右扫描 if ( $b/2-($b/$a)*$x <= $y && ($b/$a)*$x-$b/2 <= $y && ($b/$a)*$x+$b/2 >= $y && 3/2*$b-($b/$a)*$x >= $y) { echo "*"; //建立直角坐标系,当当前扫描点(x,y)在四条菱形边上或内部时,打印*号 } else echo " "; //注意:浏览器会过滤过滤多余的空格。打印空格请用左示方法 } echo "</br>";//换行 } ?> </body> </html>
$b/2-($b/$a)*$x == $y || ($b/$a)*$x-$b/2 == $y || ($b/$a)*$x+$b/2 == $y || 3/2*$b-($b/$a)*$x == $y
运行结果如下:
运行成功!
标签:开始 color error 错误提示 required 过滤 pat ror pst
原文地址:http://www.cnblogs.com/maguariji/p/7205130.html