Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE)

handsome1234 2020-06-11 11:29:36
php 7.3.4.nt


<?php
$users=[['name'=>'大叔','age'=>'16',],
['name'=>'小米','age'=>'19',],
['name'=>'小明','age'=>'23',],
['name'=>'小军','age'=>'16',],
['name'=>'小强','age'=>'19',],
];
?>
<table border="1">
<tr>
<th>编号</th>
<th> 姓名</th>
<th> 年龄</th>
</tr>
<?php
while ($user = current($users)) ;?>
<tr>
<td> <?php echo key($user) + 1; ?></td>
<td><?php echo $user['name']; ?></td>
<td><?php echo $user['age']; ?></td>
</tr>
<?php next($users);endwhile:?> //这句报错:Parse error: syntax error, unexpected 'endwhile' (T_ENDWHILE), expecting end of file in D:\phpstudy_pro\WWW\yhj.php on line 78
</table>


另外这个while后面部分应该 有{}括号的,也没有,视频上居然也没报错,真怀疑他是book air 下 php 的那个版本?
...全文
277 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
handsome1234 2020-06-12
  • 打赏
  • 举报
回复
改成这个,就Ok 了。 <td> <?php echo intval(key($user)) + 1; ?></td>
handsome1234 2020-06-11
  • 打赏
  • 举报
回复
新问题:Warning: A non-numeric value encountered in 明天看吧,今天要睡了,明天还要上班。
handsome1234 2020-06-11
  • 打赏
  • 举报
回复
看了外文资料https://stackoverflow.com/questions/54462992/how-to-fix-unexpected-endwhile-error,和我错的人还挺多,解决了: while():

<table border="1">
    <tr>
        <th>编号</th>
        <th> 姓名</th>
        <th> 年龄</th>
    </tr>
    <?php
    while ($user = current($users)) :?>
    <tr>
        <td> <?php echo key($user) + 1; ?></td>
        <td><?php echo $user['name']; ?></td>
        <td><?php echo $user['age']; ?></td>
    </tr>
    <?php next($users);endwhile;?>
</table>

既然上面有了冒号:,下面又有了endwhile,那我看也没必要有{},撤去即可。
笔记本的风扇控制 ---------------------------------------- 09 November 2006. Summary of changes for version 20061109: 1) ACPI CA Core Subsystem: Optimized the Load ASL operator in the case where the source operand is an operation region. Simply map the operation region memory, instead of performing a bytewise read. (Region must be of type SystemMemory, see below.) Fixed the Load ASL operator for the case where the source operand is a region field. A buffer object is also allowed as the source operand. BZ 480 Fixed a problem where the Load ASL operator allowed the source operand to be an operation region of any type. It is now restricted to regions of type SystemMemory, as per the ACPI specification. BZ 481 Additional cleanup and optimizations for the new Table Manager code. AcpiEnable will now fail if all of the required ACPI tables are not loaded (FADT, FACS, DSDT). BZ 477 Added #pragma pack(8/4) to acobject.h to ensure that the structures in this header are always compiled as aligned. The ACPI_OPERAND_OBJECT has been manually optimized to be aligned and will not work if it is byte-packed. Example Code and Data Size: These are the sizes for the OS- independent acpica.lib produced by the Microsoft Visual C++ 6.0 32- bit compiler. The debug version of the code includes the debug output trace mechanism and has a much larger code and data size. Previous Release: Non-Debug Version: 78.1K Code, 17.1K Data, 95.2K Total Debug Version: 155.4K Code, 63.1K Data, 218.5K Total Current Release: Non-Debug Version: 77.9K Code, 17.0K Data, 94.9K Total Debug Version: 155.2K Code, 63.1K Data, 218.3K Total 2) iASL Compiler/Disassembler and Tools: Fixed a problem where the presence of the _OSI predefined control method within complex expressions could cause an internal compiler error. AcpiExec: Implemented full region support for multiple address spaces. SpaceId is now part of the REGION object. BZ 429 ---------------------------------------- 11 Oc

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧