-
The if statement is still very fast to execute, and it doesn't need to be optimized.
-
Use ** indentation to distinguish the nested hierarchy of if statements.
Use the tooltip information to distinguish braces pairing information.
Use the folding function of the device to fold up the irrelevant logic and highlight the if level.
-
{} inside is an independent statement, which has nothing to do with the outside, and you can also write a string of judgments like you do, for example:
-
1. Just look at the program in your second picture, you should have also run it, no problem, but is numeric is to detect whether the variable is a number or a string of numbers, for example:'12345'with'', all correct, you have to know this;
2. Let's take a look at the program on your first picture:
1) Your first judgment if($theif=0) is not right, = represents the assignment rather than the judgment, it should be if($theif==0), or you can directly if($theif), because 1 and 0 represent true and false respectively when judging.
2) Your second judgment isset(), this function is to determine whether the variable exists, why it needs to be output if it already exists"It can't be empty"?Should be! isset()。
The above is an interpretation of your program, you can make a few more breakpoint output judgments in the program, which will help you know the problem of the program faster.
-
I like the logical structure below, FYI:
errstr = "";Error messages.
outstr = "";Execution result.
if ($in_deport=='') $errstr .= "Error 1";
if ($out_deport=='') $errstr .= "Mistake 2";
if ($in_deport==out_deport) $errstr .= "Error 3";
if ($errstr==''){
sql='..';
if (!res) $errstr .= "Error 4";
if ($errstr==''){
sql='..';
if (.errstr .= "Mistake 5: Insufficient inventory";
if ($errstr==''){
sql='..';
if (.errstr .= "Mistake 6: It doesn't exist";
if ($errstr==''){
sql='..';
if (.errstr .= "Error 7: Failed to write to the database";
else $outstr .= "The data was written to the database successfully";
echo<<$errstr
outstr
end;
-
If an exception occurs earlier, you should return the operation directly. For example, do the prompt if(!).$res)
sql = "Check that the product is in stock enough";
res1 = '';
if(!$res1)
sql = "Check if the product is in the warehouse";
res2 = '';
if(!$res2)
else
-
With the associated array, as follows:
arr = array(
1"=>"30",2"=>"10",3"=>"57",4"=>"99",5"=>"80",6"=>"97",7"=>"135",8"=>"40",;$sz += $arr[$sum];
Concentrate the parts that will change in the associated array $arr, and then maintain and change, just change the $arr array.
-
Using PHP nested ifesle implementation, here's an example that will solve your problem.
get['a'];Here, get the get value of the version and change it to your get session
echoa;if($a
0)else
On weekends, I often go hiking with my family, and my parents have been interested in mountaineering since they were in love, and I have been influenced by them. Of course, when you climb the mountain, you can develop self-confidence to overcome all difficulties and realize the value of teamwork. In addition, I especially enjoyed group activities, and I participated in many service activities and club activities in elementary, junior and high school, and through these activities, I met different types of friends, seniors, and juniors, and expanded my interpersonal relationships. >>>More
A high school history teacher once told us, "If you make a close friend in school, that's your greatest asset." A true friend is one that accompanies you for life. >>>More
I think the first thing the landlord knows is,Why:name='"+name+"', and tel="+ is not added to the back of the tel"'。 >>>More
This passage of English literature would be blunt if translated literally. The following is a partial paraphrase to ensure that the sentence is fluent and faithful to the original meaning: >>>More
It's me Lin Junjie You typed the lyrics wrong.