fl00d
01-07-2008, 03:25 AM
Hello,
I've been wondering (and searching) for a while now, why does die() stop HTML output? I thought it could only control the rest of the PHP script, not the rest of the page. For example:
<html>
<head>
<title>PHP Die() Example</title>
</head>
<body>
<?php
$cheese = "Jack";
if($cheese == "Cheddar"){
echo "This is the best cheese!";
}else{
echo "Your taste in cheese disappoints me!");
die();
}
?>
<div id="footer">Copyright©2008 PHP Die Cheese Example</div>
<img src="super-cheese.png" alt="Cheddar Cheese at Its Best!" />
</body>
</html>
Now if I were to execute that, the copyright and image would not show up because the $cheese isn't cheddar. Does anyone know why the copyright and image would not show up?
This has been puzzling me for a while :(
I've been wondering (and searching) for a while now, why does die() stop HTML output? I thought it could only control the rest of the PHP script, not the rest of the page. For example:
<html>
<head>
<title>PHP Die() Example</title>
</head>
<body>
<?php
$cheese = "Jack";
if($cheese == "Cheddar"){
echo "This is the best cheese!";
}else{
echo "Your taste in cheese disappoints me!");
die();
}
?>
<div id="footer">Copyright©2008 PHP Die Cheese Example</div>
<img src="super-cheese.png" alt="Cheddar Cheese at Its Best!" />
</body>
</html>
Now if I were to execute that, the copyright and image would not show up because the $cheese isn't cheddar. Does anyone know why the copyright and image would not show up?
This has been puzzling me for a while :(