Home  >  Article  >  Backend Development  >  Bad Wolf's PHP Learning Tutorial Day 3 Page 1/2_PHP Tutorial

Bad Wolf's PHP Learning Tutorial Day 3 Page 1/2_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:51:45762browse

Today I’ve taken it to the next level... First write one: (adding numbers)

Copy the code The code is as follows:

$a = "10"; //"Connect" the right side to the left side
$a += "2"; //"Add" the right side to the left side
echo $a."
n"; //The result here is 12, which probably means that $a is equal to 10, and then add 2 to the left (which is $a), so it is 12.
?>

I think PHP writing pays great attention to the concept of rows. No matter what $a represents, it probably means right to left. "Connect to" or "Add to" or "Reduction to" etc.,! is not just the addition of numbers. There are other ways.
Write another: (right connection to left content)

Copy code The code is as follows:

$b = "Bad Wolf";
$b .= "Good guy!";
$b .= "Good guy!";
echo $b."Haha!n"; //Display the final content!
?>


Why are the results displayed like this? If you listen carefully every time, you will say in the previous paragraph: The running method of the program is from top to bottom, from right to left.


Write another one: (for division)


Copy code The code is as follows:

$a = "65896255618562314793123219"; //Complex calculation here, it turns out that php handles it here easily!
$a /= "465342233234234"; //Multiply these two numbers!
echo $a."←This is the result! 65896255618562314793123219 Except for 465342233234234, wow ordinary people are not as fast as me! Haha@! N "
? & Gt;


Get results 141608156132, the speed is really fast, haha ​​.... ..

Continue to the next big step:
1. Bit operation (this is rarely used)
& stands for and (and)
| stands for or (or)
^ represents mutual exclusion (Xor)
<< Want to shift left
>> Shift right
~ Take the auxiliary number of 1
2. Logical operations (conditions, etc.)
< means less than
> means greater than
<= less than or equal to
>= greater than or equal to
== equal to (general checks such as the user's login is not equal to the condition)
!= is not equal to
&& and and (and)
|| or or (or)
xor mutually exclusive (Xor)
! Not (Not)
Other symbols
3. Other operations
$ variables (used many times)
& indicators of variables (added before variables)
@ do not display error messages (added before functions)
Examples

Copy code The code is as follows:

@include("dbx.txt"); / /If dbx.txt does not exist, an error will be reported, but it will not be displayed after adding @!
echo "
n";
?>


-> The method or attribute of the object
=> The element value of the array
?: Three far operators


Just remember the above, (But it’s not that easy to remember, haha!)
The higher-level ones are introduced below, which are also the more commonly used and key ones when writing programs!

1. Single-line if (judgment)
if. ..else...
If...what, what...what will be the result...responsible...how...
If...you are fat...you are a piglet... Otherwise... you are a skinny monkey.
if(conditon) { statment1} true
else {statment2} false false
Example:

$a = 4.998;
if($a > 5) //No semicolon is needed here, pay attention!
{
echo "Yes! a > 5n";
}
else       // No semicolon is needed here, pay attention!
                                                                                                                                                   



http://www.bkjia.com/PHPjc/319111.html
www.bkjia.com

truehttp: //www.bkjia.com/PHPjc/319111.htmlTechArticleToday we have reached a new level...Write first: (adding numbers) Copy code code As follows: ?php $a="10";//"Connect" the right side to the left side $a+="2";//"Add" the right side to the left side echo$a."brn";//The result here is. ..
Statement:
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
Previous article:PHP Learning File Processing and File Upload Courseware Page 1/2_PHP TutorialNext article:PHP Learning File Processing and File Upload Courseware Page 1/2_PHP Tutorial

Related articles

See more