I have been learning PHP for a long time. I would like to share my little experience with you here. PHP is a server scripting language used to create dynamic web pages. Like ASP and ColdFusion, users can use PHP and HTML to write WEB pages. When a visitor browses this page, the server first processes the PHP commands on the page, then, the processed results and HTML content are sent to the browser at the access end.
However, unlike ASP or ColdFusion, PHP is an open source code program with good cross-platform compatibility. You can run PHP on Windows NT and many versions of Unix systems, and run PHP as a built-in module of the Apache server or CGI program. In addition to precisely controlling the content displayed on the web page, you can also use PHP to send HTTP headers. Users can set cookies through PHP, manage user identification, and redirect user browsing pages. PHP has very powerful database support functions and can access almost all of the more popular database systems. In addition, PHP can be integrated with multiple external libraries to provide users with more practical functions, such as generating PDF files.
You can directly enter the PHP Command code on the WEB page without any special development environment. On the WEB page, all PHP code is placed in "<? Php "and"?>" . In addition, you can also select a format such as <script language = "php"> </SCRIPT>. The PHP engine automatically identifies and processes all code on the page between PHP delimiters. The syntax structure of PHP script is very similar to that of C and Perl. You do not need to declare variables before using them. Using PHP to create an array is also very simple. PHP also has basic object-oriented component functions, which greatly facilitates users to effectively organize and encapsulate their own code. Today, I want to introduce how to obtain PHP in a day of the week.
PHP day of the week to get the code:
- Date ("l ");
- // Data can be used to obtain the English week, such as Sunday.
- Date ("w ");
- // You can obtain the number of weeks, for example, 123. Note that 0 is Sunday.
You can obtain the Chinese Week.
- $Weekarray= Array ("day", "one", "two", "three", "four", "five", "Six ");
- Echo "Week". $ weekarray [date ("w")];
Obtain the specified date:
- $Weekarray= Array ("day", "one", "two", "three", "four", "five", "Six ");
- Echo "Week". $ weekarray [date ("w", "2011-11-11")];
Because the date function is very powerful, he is fully qualified for all such work. I have attached a table in the manual.
- A-"am" or "pm"
- A-"AM" or "PM"
- D-a few days, two digits. If there are less than two digits, fill in the first zero. For example, "01" to "31"
- D-the day of the week, with three English letters, for example, "Fri"
- F-month, full English name; for example: "January"
- H-12 hours, for example, "01" to "12"
- H-24 hours, for example, "00" to "23"
- Hours in the g-12 hour format. Less than two hours do not fill in zero. For example: "1" to 12"
- Hours in the G-24-hour format. Less than two hours do not fill in zero. For example: "0" to "23"
- I-minutes; for example: "00" to "59"
- J-a few days, two digits. If less than two digits are left blank, for example, "1" to "31"
- L-the day of the week, full name in English; for example: "Friday"
- M-month, two digits. If there are less than two digits, add zero in front, for example, "01" to "12"
- N-month, two digits. If less than two digits are left blank, for example, "1" to "12"
- M-month, with three English letters, for example, "Jan"
- S-seconds; for example: "00" to "59"
- The end of the S-character is followed by an English sequence, with two English letters, for example, "th", "nd"
- T-specifies the number of days in a month, for example, "28" to "31"
- U-total seconds
- W-number of weeks, for example, "0" (Sunday) to "6" (Saturday)
- Y-year, four digits, such as: "1999"
- Y-year, two digits, for example, "99"
- Z-the day of the year, for example, "0" to "365"
The above describes in detail how to obtain the PHP day of the week and the date function. Please try it.