扫码关注官方订阅号
<?php if(!isset($a)): xxx; endif;
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
主要是在 HTML 模板里用这种写法比较清晰,尤其当配合 short_open_tag 时。
<? if(isset($a)): ?> <? if($a): ?> <span>variable a is exist and not empty</span> <? endif; ?> <? endif; ?>
作为对比,要比下面的写法好看一点,尤其是当逻辑复杂的时候,很可能分不清花括号。
<? if(isset($a)) { ?> <? if($a) { ?> <span>variable a is exist and not empty</span> <? } ?> <? } ?>
http://php.net/manual/zh/control-structures.alternative-syntax.phphttp://php.net/manual/zh/ini.core.php#ini.short-open-tag
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
主要是在 HTML 模板里用这种写法比较清晰,尤其当配合 short_open_tag 时。
作为对比,要比下面的写法好看一点,尤其是当逻辑复杂的时候,很可能分不清花括号。
http://php.net/manual/zh/control-structures.alternative-syntax.php
http://php.net/manual/zh/ini.core.php#ini.short-open-tag