当我拿出<?php ?>
下面的HTML代码时,网页不再加载。为什么以下依赖于该代码?我对这个问题的特殊性感到抱歉,但这真让我感到沮丧,我似乎无法独立找到答案。
<?php
/*Write a function to return an HTML <img /> tag. The function should accept a
mandatory argument of the image URL and optional arguments for alt text,
height , and width
*/
function html_img ($img_url = "\"https://img.purch.com/h/1400/aHR0cDovL3d3dy5saXZlc2NpZW5jZS5jb20vaW1hZ2VzL2kvMDAwLzA5OS8zMjkvb3JpZ2luYWwvY2hpbXBzLWVhdC1tb25rZXktYnJhaW5zLTAx\"", $alt_text = "\"ronald\"", $height = 400, $width = 1200){
$the_format = "<img src=" . $img_url . "alt=" . $alt_text . " height" . $height . " width=" . $width;
return $the_format;
}
print html_img();
?>
<!--When the code below is removed, the image is not displayed.-->
<!-- <img src="https://img.purch.com/h/1400/aHR0cDovL3d3dy5saXZlc2NpZW5jZS5jb20vaW1hZ2VzL2kvMDAwLzA5OS8zMjkvb3JpZ2luYWwvY2hpbXBzLWVhdC1tb25rZXktYnJhaW5zLTAx" -->
$the_format
中的图像标签是未闭合的,因此它可能出现在标记中(查看页面源)但如果没有关闭>
或/>
,它将不会以HTML格式呈现