Bad Wolf PHP Learning tutorial on the 2nd Day _php Foundation

Source: Internet
Author: User
Tags object object true true
1. Basic wording:

echo "Buy a virtual host to find Bad Wolf!" Www.winshell.cn\n ";
Here is PHP to write content! "\ n" is a line-wrapping ";" The representative will be more than the end of the line. No error will be added.

2. The program's Practice:
The program runs from top to bottom, from right to left,
To come back with special control,
The way the program stops, the end of the run, the termination of the error, and the end of the instruction.
3. Note When writing a program
Do not use the variables as far as possible, such as a=123, but the program can not be used, is wasted, the program will also be slow. Reduce the number of test writing, reduce waste code. For example, to judge the other is a male and female aliens or something.
Consider the flexibility of the program (do not need to write is not used, convenient debugging, press the TAB key to change lines.) The same as the same. Develop a good habit of writing programs.
Indent and bracket should be symmetrical. Control of the amount of data (variable name length, rule short good) variables such as: aaa.php?id=2222
4. Reference file Mode:
Require ("file name");   Introduce failure to hang (Error) Error! Remember the word "Rachel de".
Include ("file name"); The introduction of failure does not bird it (Warning) a warning! Remember the word "due to virtue"
There are other require ("Db.txt"); Include ("Db.txt"); References the Db.txt file in the same directory.
If Db.txt does not exist, require will make a page error.
If Db.txt does not exist, the include style will only make the current line error.
5. Program annotation
Single note, two-apostrophe * */oblique star-Star tilt
* * Here to write the content to annotate, how to write all the line, write how many! You can't see me * *
6. Constants and variables
Constant ex. For example, pi is usually a common number, hehe!
Variable ex. $x, $y, $z.
7. The form of constants
True True
Fals Fake
8. The shape of the variable
String string
Integer integers 123456780
Double floating-point number has 1.2 of the decimal point
Array array
Object Object
9. Use of variables (\ "variable quotes \ backslash \ n line break \ r) send out \ t tab)
Use reserved words
plus $ take it to use
Loose morphological transitions
Free of Proclamation
About global $ variables for domain variables
10. Quotation marks for variables
Single quotes ' Don't work.
Double quotes "" PHP to help you deal with.
$a = "Bad Wolf";
$b = "Sell virtual host!";
echo "$a! $a! is $b!!! ";
12. Operation Symbol
Number, text, logic.
An important part of a program
Understand and check the table.
13. Arithmetic operation
+ Addition-Subtraction * multiplication/division% of the remainder (8/3 remainder is 2) + + cumulative 1--Descending 1
14. Operation of String
. Point = Equals
15. Set operation
= Connect the right value to the left
+ = Add the right value to the left
-= reduce the value on the right to the left
*= the value on the left to the right
/= the left value to the right
%= the left value to the right to the remainder
. = Add the right string to the left
Test the code you wrote today! and to create 1 db.txt in the same directory, writing boring stuff.
Copy Code code as follows:

<title> buy a virtual host to find Bad Wolf </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body>
<?php
Require ("Db.txt");
The way you refer to the file you require ("File content!"); If you can't find the contents of the file, it will all stop!
echo "<br>";
This shows 1 line break <br>
Include ("Db.txt");
The way you refer to the file include ("File content!"); If you can not find the contents of the file, only when the line out error prompts!
echo "<br>";
This shows 1 line break <br>
echo "Buy a virtual host to find Bad Wolf!" <br>www.winshell.cn\n ";
Here is PHP to write content! "\ n" is a line-wrapping ";" The end of the line to be more words to add
/* You can't see me! You can't see me! You can't see me! */
?>
<br>
<?php
$a = "Bad Wolf";
$b = "Sell the virtual host!";
echo "$a! $a! is $b!!! ";
echo "<br>";
Echo ' $a! $a! It's $b!!! Here is the single quotation mark part, does not do the processing. '; Single quotation marks do not do processing!
?>
<br>
<?php
$a = "yes";
$b = "Good Oh!";
$c = $a. $b; Add the contents of $a and $b to $c
echo $c. "<p>";
$c = $c. $a. $b;
echo $c. "<p>";
?>
<?php
$a = "8";
$b = "2";
$c = "3";
echo $a + $b. "<br>\n"; Look at the source file and see the line!
Echo $a-$b. "<br>\n";
Echo $a * $b. "<br>\n";
echo $a/$b. "<br>\n";
echo $a% $b. "<br>\n";
$a + +;
echo $a. " <br>\n ";
$c--;
echo $c. " <br>\n ";
?>
</body>

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.