I do not understand this PHP Code, what is it doing?

This question already has an answer here:

  • Reference — What does this symbol mean in PHP? 18 answers

  • colons - this is a shorthand version of statements, you should not really learn them at such an early stage. First you need to learn the full versions.

  • <?= $variable ?> is a short version of <?php echo $variable ?> but means exactly the same.

  • Also, the shordhand versions from question one are actually not considered a good practice, because when you nest them they are hard to read.


    Colons on lines 1 and 3 are an alternative way of doing the below code

    if (!empty($data)) {
        ...
    }
    

    It makes it a lot cleaner when outputting HTML.

    (See http://php.net/manual/en/control-structures.alternative-syntax.php)

    <?= is a shorthand way of writing <?php echo , again it's just an alternative way of doing things.

    (See http://php.net/manual/en/function.echo.php)


    你可以在php中写很多类型的循环......例如:if(condition){... code ...} else {... code ...}或if(condition):代替“ {“你可以使用”:“并结束循环使用”endif“2)你的第2点是用php的shortcode编写的,因为你必须在php.ini中启用shortcode

    链接地址: http://www.djcxy.com/p/59360.html

    上一篇: 使用DataContractSerializer时,忽略运行时的某些属性

    下一篇: 我不明白这个PHP代码,它在做什么?