Bad Wolf PHP Learning Tutorials 3rd day 1th/2 page _php Basics

Source: Internet
Author: User
It's 1 floors today ... Write 1 First: (Numbers added)

Copy Code code as follows:

<?php
$a = "10"; "Connect" to the left of the right
$a + + "2"; Add the right to the left.
echo $a. "  <br>\n "; The result here is 12, probably means, $a equals 10, then adds 2 to the left (that's $a), so it's 12.
?>

I think PHP is very focused on the concept of line, no matter what $a represents, probably mean to the right to the left. Connect to "or" add to "or" subtract "and so on,! Not just the Gallian between numbers. There are other ways.
Write 1 more: (right to left content)

Copy Code code as follows:

<?php
$b = "Bad Wolf";
$b. = "Good man!";
$b. = "Good man!";
echo $b. " Hehe!\n "; Show Final content!
?>


Why did the result show? If you listen carefully every time, the previous paragraph will say: The program is run from top to bottom, from right to left principle.


Write 1 more: (Division)


Copy Code code as follows:

<?php
$a = "65896255618562314793123219"; Here the complexity of the calculation, the original PHP processing here simple!
$a/= "465342233234234"; Multiply these 2 numbers!
echo $a. " ← This is the result!65896255618562314793123219 divided by 465342233234234, wow average people do not I fast! hehe @!\n "
?>


Get the result 141608156132, calculate the speed is really fast, hehe ...

Proceed to the next 1 major steps:
1. Bitwise operations (this is rarely used)
& Representative and (and)
| Representative or (or)
^ Representing mutexes (Xor)
<< want to shift left
>> Shift Right
~ Take 1 of the auxiliary number
2. Logical operation (condition, etc.)
< represents less than
> represents greater Than
<= less than or equal to
>= is greater than or equal to
= = Equals (General check for example user login equals not equal to condition)
!= is not equal to
&& and (and)
|| or or (or)
XOR Mutex (XOR)
! No (not)
Other symbols
3. Other operations
$ variables (used many times)
Index of & variables (plus before variables)
@ Do not display error message (added to function)
Example

Copy Code code as follows:

<?php
@include ("Dbx.txt"); If the dbx.txt does not exist, it will report an error, but the @ will not show!
echo "<br>\n";
?>


-> methods or properties of an object
element values for the => array
?: three far operator


Remember on the top can be, (but remember also not so easy, hehe!)
Below the introduction of more high-level, but also write procedures more commonly used key!

1. if (judgment) of a single line
If...else ...
If... What, what? How it turned out ... Responsible for... How...
If... You're fat ... You're a piggy. Otherwise... You're a skinny monkey.
if (Conditon) {Statment1} true True
else {Statment2} false false
Example:

<?php
$a = 4.998;
if ($a > 5)//No need to add a semicolon here, attention!
{
echo "to the!a > 5\n";
}
else//here does not need to add a semicolon, note!
{
echo "Wrong!a < 5\n";
}
?>

Current 1/2 page 12 Next read the full text

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.