Php 使用和多个else if语句-输出意外的文件结尾
我一直在尝试回显代码,但它没有正常工作。在阅读了ifelse语句之后,我仍然无法理解php中的这条语句输出意外的文件结尾有什么问题Php 使用和多个else if语句-输出意外的文件结尾,php,Php,我一直在尝试回显代码,但它没有正常工作。在阅读了ifelse语句之后,我仍然无法理解php中的这条语句输出意外的文件结尾有什么问题 <?php if($current_type){?> <?php echo " Manage Product Type "; echo "Menu Name:". $current_type["product_type"]."<br>";?> <a h
<?php if($current_type){?>
<?php echo " Manage Product Type ";
echo "Menu Name:". $current_type["product_type"]."<br>";?>
<a href= "edit_category.php">Edit Subject</a>;
<?php}elseif($current_category){?>
<h1> Manage Product category </h1>
<?php echo "Menu Name:". $current_category["category_name"];?>
<?php}elseif ($current_product){?>
<h1> Manage Products </h1>
<?php echo "Menu Name:". $current_product["product_names"];?>
<?php }else{?>
Please select a Product, category, or type
<?php};?>
;
管理产品类别
管理产品
请选择产品、类别或类型
试试这个
<?php if($current_type){ ?>
<?php echo " Manage Product Type ";
echo "Menu Name:". $current_type["product_type"]."<br>";?>
<a href= "edit_category.php">Edit Subject</a>;
<?php } else if($current_category){ ?>
<h1> Manage Product category </h1>
<?php echo "Menu Name:". $current_category["category_name"];?>
<?php } else if ($current_product){?>
<h1> Manage Products </h1>
<?php echo "Menu Name:". $current_product["product_names"];?>
<?php } else {?>
Please select a Product, category, or type
<?php }?>
;
管理产品类别
管理产品
请选择产品、类别或类型
这是对代码可读性的巨大改进。它使用
管理产品类型
菜单名:
管理产品类别
菜单名:
管理产品
菜单名
请选择产品、类别或类型
使用此原理
括号后的最后一行中不应该有分号。在注释之前,您是否在没有分号的情况下运行它。。。
<?php if($current_type): ?>
<h1>Manage Product Type</h1>
Menu Name: <?php echo $current_type["product_type"] ?><br>
<a href="edit_category.php">Edit Subject</a>
<?php elseif ($current_category): ?>
<h1>Manage Product category</h1>
Menu Name: <?php echo $current_category["category_name"] ?>
<?php elseif ($current_product): ?>
<h1>Manage Products</h1>
Menu Name <?php echo $current_product["product_names"] ?>
<?php else: ?>
Please select a Product, category, or type
<?php endif ?>
Use this rationale
<?php if(1 == 1) { ?>
<?php echo "xxxxx"; ?>
<?php } elseif(1 == 2) { ?>
<?php echo "xxxxx"; ?>
<?php } elseif (1 == 3){ ?>
<?php echo "xxxxx"?>
<?php } else { ?>
<?php echo "xxxxx"?>
<?php } ?>