Tutorial on Bad Wolf's PHP: Page 3rd, 1/2

Source: Internet
Author: User
Tags dbx

Today, I got to the next level... first write one: (numbers are added)

 Copy codeThe Code is as follows:
<? Php
$ A = "10"; // connect "to the left
$ A + = "2"; // Add "on the right" to the left
Echo $. "<br> \ n"; // here the result is 12, which means that $ a equals 10, and then adds 2 to the left (that is, $ ), so it's 12.
?>

In my opinion, php statements focus on the concept of line. Whatever $ a represents, it generally means connecting to the right. "connecting to" or "adding" or "Reducing ,! It is not just a combination of numbers. Other methods are also supported.
Write another one: (Right to left)

 Copy codeThe Code is as follows:
<? Php
$ B = "Bad Wolf ";
$ B. = "good guy! ";
$ B. = "good guy! ";
Echo $ B. "haha! \ N "; // display the final content!
?>


Why is the result displayed like this? If you listen carefully every time, the previous section will say that the program runs from top to bottom and from right to left.


Write another one: (Division)


 Copy codeThe Code is as follows:
<? Php
$ A = "65896255618562314793123219"; // complicated computing here. The original php processing is simple here!
$ A/= "465342233234234"; // multiply the two numbers!
Echo $ a. "success this is the result! 65896255618562314793123219 divided by 465342233234234, wow, ordinary people's arithmetic is not as fast as me! Haha @! \ N"
?>


Expected result 141608156132 is displayed. The calculation speed is really fast ......

Next step:
1. bitwise operations (this is rarely used)
& Represents and (and)
| Represents or (or)
^ Indicates Mutual Exclusion (Xor)
<Want to shift left
> Shift to the right
~ Take the secondary number of 1
2. logical operations (conditions, etc)
<Represents less
> Greater
<= Less than or equal
> = Greater than or equal
= (Generally, check whether a user's login is equal to or not)
! = Not equal
& And (and)
| Or (or)
Xor)
! No (Not)
Other Symbols
3. Other operations
$ Variable (used many times)
& Variable indicators (before a variable)
@ Do not display the error message (before the function)
Example

Copy codeThe Code is as follows:
<? Php
@ Include ("dbx.txt"); // If dbx.txt does not exist, an error is reported, but it is not displayed after @ is added!
Echo "<br> \ n ";
?>


-> Object methods or attributes
=> Array element value
? : Triplicate Operator


Remember the above, (but it is not that easy to remember, huh, huh !)
Next we will introduce the higher level, which is also the key to writing programs!

1. if (judgement) of a single row)
If... else...
If... what is... how is the result... is responsible... how...
If you are fat... you are a pig... otherwise... you are a thin monkey.
If (conditon) {statment1} true
Else {statment2} false
Example:

<? Php
$ A = 4.998;
If ($ a> 5) // no extra points are required here. Note!
{
Echo "Yes! A> 5 \ n ";
}
Else // no extra points are required here. Note!
{
Echo "error! A <5 \ n ";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.