Bad Wolf's PHP learning tutorial-2nd-PHP Tutorial

Source: Internet
Author: User
2nd days of Bad Wolf's PHP learning tutorial. 1. basic syntax: echo buys a VM and finds a Bad Wolf! Www. winshell. cnn; here is the content to be written by php! N indicates a line break. if there are too many lines to end, it must be added. no error will be reported. 2. program execution: Process 1. basic syntax:

Echo "buy a VM and find a bad wolf! Www.winshell.cn \ n ";
// Here is the content to be written by php! "\ N" indicates a line break ";" indicates adding more lines to the end. no error is returned.

2. program execution:
Programs run from top to bottom, from right to left,
You can only go back when you encounter special control,
Stop the program.
3. pay attention when writing a program
Do not use unnecessary variables, such as a = 123. if the program is not used, it is a waste and the program will slow down. reduce testing writing and waste code. for example, determine whether the other person is a male, female, or alien.
Consider the elasticity of the program (do not use anything you do not need to write, so that you can easily debug the program and press the tab key to wrap the line. use the same pair of similar features. develop good writing habits and have rules)
The contraction and arc should be symmetric. data volume control (variable name length, shorter rules) variables such as aaa. php? Id = 2222
4. file reference method:
Require ("file name"); an Error is reported if the import fails! Note the word "rikuelde"
Include ("file name"); if the import fails, it will not give a Warning! Note the word "because it can be entered"
Other require ("db.txt"); include ("db.txt"); reference the db.txt file in the same directory.
If db.txt does not exist, The require writing method will cause a page error.
If db.txt does not exist, the include statement only reports an error for the current row.
5. program Comments
// Single-row comment, two-byte/**/oblique star-star skew
/* Write the content to be commented on here. you can write anything and write anything! You cannot see me */
6. constants and variables
Constant ex. for example, the circumference rate is a common number!
Variable ex. $ x, $ y, $ z ..
7. constant morphology
True
Fals false
8. variable form
String
Integer 123456780
Double floating point number has a decimal point of 1.2
Array
Object
9. variable usage (\ "variable quotation marks \ backslash \ n line feed \ r output \ t hop TAB)
Use reserved words
Add $ to use
Loose form conversion
Do not declare
Global variables
10. variable quotation marks
Single quotes ''have no effect.
Double quotation marks "" php help you deal.
11. $ a = "Bad Wolf ";
$ B = "selling virtual hosts! ";
Echo "$! $! Yes $ B !!! ";
12. operator number
Numbers, text, logic ..
An important part of the program
Understanding, look up the table ..
13. Arithmetic operations
+ Addition-subtraction * multiplication/division % remainder (the remainder of 8/3 is 2) + + accumulate 1 -- Decrease 1
14. string operation
. Point = equal
15. set operations
= Connect the value on the right to the left
+ = Add the right value to the left
-= Reduce the value on the right to the left
* = Multiply the value on the left to the right.
/= Remove the left value to the right
% = Returns the remainder of the left value to the right.
. = Add the string on the right to the left
Code written by myself today! We also need to create 1 db.txt in the same directory to write boring stuff.

The code is as follows:




Buy a VM to find the wolf



Require ("db.txt ");
// File reference method you require ("file content! "); If the file content cannot be found, it will all stop!
Echo"
";
// One line feed is displayed here.

Include ("db.txt ");
// You include ("file content! "); If the file content cannot be found, an error prompt is displayed!
Echo"
";
// One line feed is displayed here.

Echo "buy a VM and find a bad wolf!
Www.winshell.cn \ n ";
// Here is the content to be written by php! "\ N" indicates line feed ";" ends. if there are many lines, add
/* You cannot see me! You cannot see me! You cannot see me! You cannot see me! */
?>


$ A = "Bad Wolf ";
$ B = "sold for virtual hosts! ";
Echo "$! $! Yes $ B !!! ";
Echo"
";
Echo '$! $! Yes $ B !!! // Here is the single quotation mark, so it will not be processed. '; // it will not be processed in single quotation marks!
?>


$ A = "yes ";
$ B = "Okay! ";
$ C = $ a. $ B; // add the content of $ a and $ B to $ c
Echo $ c ."

";
$ C = $ c. $ a. $ B;
Echo $ c ."

";
?>
$ A = "8 ";
$ B = "2 ";
$ C = "3 ";
Echo $ a + $ B ."
\ N "; // The \ n line breaks when you view the source file!
Echo $ a-$ B ."
\ N ";
Echo $ a * $ B ."
\ N ";
Echo $ a/$ B ."
\ N ";
Echo $ a % $ B ."
\ N ";
$ A ++;
Echo $ ."
\ N ";
$ C --;
Echo $ c ."
\ N ";
?>



Invalid echo "buy a VM to find a bad wolf! Www.winshell.cn \ n "; // the content to be written in php! "\ N" indicates a line break ";" indicates that a line break is added if there are too many lines to end. no error will be reported. 2. program execution: process...

Related Article

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.