I 'd like to share with you the score of my first two hours of learning php (applicable to Cainiao)-php Tutorial

Source: Internet
Author: User
I want to share with you my score for the first two hours of learning php (suitable for beginners): PHPcodewww.w3school.com. cnphp1.php. the file must be: & lt ;? Write the php statement here? & Gt; 2. echo output function method: echo "abc" 3. define variable: $ variable name variable value 4. use ". "Connection example: echo $ variable to share with you the score of my first two hours of learning php (suitable for beginners) (hash)
Learning from:
PHP code
  http://www.w3school.com.cn/php/

1. the php file must be:
Write the statement here
?>
2. echo output function method: echo "abc"
3. define the variable: $ variable name = variable value
4. join the two variables with "." for example, echo $ Variable 1. Variable 2.
5. the strlen () function indicates the length of the variable value.
For example echo strlen ("Hello world !"); Output 12
6. the strpos () function indicates to retrieve the position of a string in a string.
7. Operators
Arithmetic operators
Operator example result
+ Additionx = 2
X + 24
-Subtractionx = 2
5-3
* Multiplicationx = 4
X 520
/Division15/5
5/23
2.5
% Modulus (pision remainder) 5% 2
10% 8
10% 21
2
0
++ Incrementx = 5
X ++ x = 6
-- Decrementx = 5
X -- x = 4
Value assignment operator
Operator example
= X = yx = y
+ = X + = yx = x + y
-= X-= yx = x-y
* = X * = yx = x * y
/= X/= yx = x/y
. = X. = yx = x. y
% = X % = yx = x % y
Comparison Operators
Operator example
= Is equal to5 = 8 returns false
! = Is not valid 5! = 8 returns true
> Is greater than5> 8 returns false
> = Is greater than or equal to5> = 8 returns false
<= Is less than or equal to5 <= 8 returns true
Logical operators
Operator example
& Amp; andx = 6
Y = 3
(X <10 & y> 1) returns true
| Orx = 6
Y = 3
(X = 5 | y = 5) returns false
! Notx = 6
Y = 3
! (X = y) returns true

8. function date ("D"); the time function returns the information of the current day.
9. define a set: $ name = array ("Liu Wencheng", "Cheng Haiyan", "myPHP ");
10. for loop
PHP code
  $ I = 0; for ($ I = 1; I <5; I ++) {echo "see my steps". $ I ."
";}

11. foreach loop
PHP code
  $ Arr = array ("one", "two", "three"); foreach ($ arr as $ value) {echo "I changed set project". $ value}

12. function definition keyword: function
PHP code
  
  

13. function w ($ name1, $ name2) -- => put parameters
14. return is used in the function to return values.
15. $ _ POST ["name"] or $ _ GET ["name"] is used to obtain the value submitted by the form.
16. $ _ COOKIE ["name"] to obtain the cookie value
17. $ _ REQUEST ["name"] contains $ _ POST $ _ GET $ _ COOKIE
18. data (format, timesamp );
Function description: time
Parameter description: format: Required. the format of the specified time.
Timesamp
Example: echo data ("y/m/d ");
Echo data ("y. m. d ");
Echo data ("y-m-d ");
The above output:
2006/07/11
2006.07.11
2006-07-11
19. mktime (hour, minute, second, month, day, year, is_dst)
Function description: time point
Is_dst is optional. other parameters are optional.
20. include ("head. php") function
Set the head. php file as the header file
For example:
PHP code
  
  Welcome to my home page

Some text


21. require ("head. php") function
Almost the same as the include () function, but the error handling method is different.
In addition to an error, include will execute the following php code, while require will return immediately
22. fopen (); open the file on the php page
There are two parameters: parameter a is the file path
Parameter B: file opening mode
Here we will explain parameter B:
"R" -- => read-only, starting from the beginning of the file
"R +" -- => read/write, starting from the file header
"W" -- => write only, open the file and clear the file content. if there is no file, create
"W +" -- => read/write, open the file and clear the file content. if there is no file, create
"A" -- => append, open the file, and write to the end of the file. if the file does not exist, create a new file.
"A +" -- => READ/append, write content to the end of the file, and keep the file
"X" -- => write-only create file. if the file exists, false is returned.
"X +" -- => read/write. If the file already exists, false and an error are returned.
Note *: if fopen () cannot open the specified file, use 0 (false)
Example 1: $ file = fopen ("D:/abc.txt", "r ");
Example 2: $ file = fopen ("D:/abc.txt", "r") or exit ("unable to open file !");
Note: In this example, if the file cannot be opened, a message is displayed.
23. feof ($ file) is used to retrieve whether the file end has been reached
Note: When the permission is w, a, x, the file cannot be opened.

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.