gpt4 book ai didi

php - 这在 PHP 中是什么语法?

转载 作者:行者123 更新时间:2023-12-04 20:55:28 25 4
gpt4 key购买 nike

if(true):
echo 'good';
endif;

我今天才在 PHP 中看到它!

我一直在使用:

if(true)
{
echo 'good';
}

最佳答案

它是 Alternative syntax for control structures .


引用手册的那一页:

PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively.


我不常看到它在“纯 PHP”文件中使用,但当 PHP 与 HTML 混合在同一文件中时,它经常被使用——即用作模板语言时。

关于php - 这在 PHP 中是什么语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2081442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com