Detailed explanation of alternative syntax in PHP

墨辰丷
Release: 2023-03-25 19:48:02
Original
1809 people have browsed it

This article mainly introduces the detailed explanation of alternative syntax in PHP. Interested friends can refer to it. I hope it will be helpful to everyone.

  • What is alternative syntax?
    Simply put, they are some alternative ways of writing grammar.

#2. What syntaxes have alternative syntaxes in PHP?

if, while, for, forforeach, switchThese flow control statements have alternative syntax.


3. Basic form of alternative syntax:

The left curly brace ({) is replaced by a colon (:), and the right The curly braces (}) are replaced with endif;, endwhile;, endfor;, endforeach; and endswitch;


Usage:

if-endif usage:

 
  • if里面的输出
  • 上面的语句等同于 if里面的输出
    Copy after login

    while-endwhile usage:

     
  • 循环while里面的输出
  • Copy after login

    for-endfor usage:

     
  • 循环for里面的输出
  • Copy after login

    switch-endswitch usage:

    Copy after login

    Related recommendations:

    php alternative syntax

    Introduction to alternative syntax in PHP, introduction to PHP alternative syntax_PHP tutorial

    ##Introduction to alternative syntax in PHP, introduction to PHP alternative syntax

    The above is the detailed content of Detailed explanation of alternative syntax in PHP. For more information, please follow other related articles on the PHP Chinese website!

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!