PHP flow control if else syntax

if and else syntax

This is a very important chapter and an important syntax in PHP.

[Note] My definition level of this grammar is: tacit writing level. That is, you can write it with your eyes closed if you need it.

Explanation in English:

*if *Pronunciation: [ɪf]
Explanation in Chinese: If

##elsePronunciation: [ɛls]Chinese explanation: Otherwise

We combine if and if...else into four basic grammars, each of which must be memorized.

 
 

Many people like to buy lottery tickets. Let’s use the process of buying lottery tickets to write an example of if.

In the chapter "3.2.2 Boolean is the Knowledge of the Book of Changes", I gave you a wretched example:

For example, a sentence often mentioned in TV dramas :If I get that beautiful girl (handsome guy), I am willing to die.

Let’s look at the flow chart and it looks like this:


2015-08-08_55c589e138f73.png

This sentence can be written using computer code:

If I pick up a beautiful girl

Then: I am willing to die
If I don’t pick up a beautiful girl
Then: I am not willing to die This is it:


For the above example, we can completely use if...else... to translate it into code:2015-08-08_55c58ab5e5076.png

 在if...

In

else, we write another example that can be enclosed in curly brackets and have multiple sentences:


Continuing Learning
||
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!