Home > Backend Development > PHP Tutorial > PHP新手来啦。第一天

PHP新手来啦。第一天

WBOY
Release: 2016-06-23 13:30:46
Original
899 people have browsed it

为什么我这段代码没输出?
直接上码吧。。。还请多多指教~~

<?phpif (isset ( $_POST ["submitted"] )) {	$x = $_POST["x"];	$y = $_POST["y"];	if ($x == 0 && $y == 0) 			$z="出错了!x与y不能同时为0。";	else{		$z = $x + $y;	}}?><html><head></head><body><form method="post">	<input type="text" name="x" value="<?php @$x?>"  />	+	<input type="text" name="y" value="<?php @$y?>"  />	<input type="submit" name="submitted" value="=" />	<input type="text" name="z" value="<?php @$z?>"  /></form></body></html>
Copy after login


回复讨论(解决方案)

你的变量没有输出,当然不行,改成这样就可以了。

<?phpif (isset ( $_POST ["submitted"] )) {    $x = $_POST["x"];    $y = $_POST["y"];    if ($x == 0 && $y == 0)             $z="出错了!x与y不能同时为0。";    else{        $z = $x + $y;    }}?> <html><head></head><body><form method="post">    <input type="text" name="x" value="<?php echo @$x?>"  />    +    <input type="text" name="y" value="<?php echo @$y?>"  />    <input type="submit" name="submitted" value="=" />    <input type="text" name="z" value="<?php echo @$z?>"  /></form></body></html>
Copy after login

if (isset ( $_POST ["submitted"] )) {
    $x = $_POST["x"];
    $y = $_POST["y"];
    if ($x == 0 && $y == 0) 
            $z="出错了!x与y不能同时为0。";
    else{
        $z = $x + $y;
    }
}
?>
  





    "  />
    +
    "  />
    
    "  />


echo出来啊 不echo怎么会有输出啊

2楼短标签写法,需要开起php短标签设置,其实这样看着更舒服

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template