My own summary of PHP knowledge _php Tutorial

Source: Internet
Author: User
Tags mysql insert
I have not learned PHP before, just recently a project needs to use, I decided to learn while doing PHP.
1 in an SQL statement, you can add a restriction: Left (text,20) takes only the first 20 words of text;
2 can be used with limit FromRecord, recordnum to use as paging, such as the limit 0,30 indicates that the first record from the beginning of the traversal of 30 records;
32 Table connections can be: Table1 join table2 using X (x is a public field for two tables), or table1 join table2 on table1.x = table2.x
4 PHP Get querystring can be used $page = $_get[' page '];
Or
$page = $_request[' page '];
Where request can obtain post,get,querystring and other characters;
Before that, I saw a more stupid approach:
Parse_str ($_server[' query_string '), $output); First, the query string is stored in an array $output
$page = $output [' page ']; Then indexed by the variable name

5 The comparison of date functions in PHP is actually a comparison of strings;
6 MySQL Date type data can be: 2000-02-03,2002.02.03,2002.2.3,02.02.03,02.2.3, that is, must have a month and day, and must be '-' or '. ' Separated.
7 data () to get time there will be a timezone problem, I found that the time is less than 8 hours, because php.ini inside the default configuration is the GTM U.S. time zone;
WORKAROUND: You can modify the php.ini:
[Date]
; Defines the default timezone used by the date functions
Date.timezone = "Asia/shanghai"
or use the date () function to add Date_default_timezone_set ("PRC");

81 time, debugging in the body always said I lacked ")", a half-day is intval ($_post[' consumetype ')) problem, in the database this field is varchar (50), in the Zengsong table I do not use intval function, is because its ID is ... integers and char can be converted to each other, but in the other two tables is a5a,sp07-01, but how does it convert to int type?
Let's take a look at the declaration of the Intval function:
The Intval function is used to get the integer value of the variable: int intval (mixed var [, int base])
Returns the integer value of the variable var by using a specific binary conversion (by default, decimal).
var can be any scalar type. Intval () cannot be used with an array or object.

9 Another inexplicable problem, to user name 1 login can, change a ' Bo ' Landing, the system is inError: Said I ran the wrong time: Missing ")", Nnd. Checked, it turns out that the variable type in the SQL statement is inconsistent with the database.
In PHP, when converting from floating-point numbers to integers, the number is rounded (discarding decimal digits).

11 in the MySQL INSERT statement, if the self-increment field is to be used (NULL) instead.
PHP is garbled in Chinese??? Problem solving:
Add mysql_query after mysql_connect ("Set names ' gb2312 '");
Or use the UTF8 code, you do not have to join the above statement.
There are also function Iconv ("GBK", "UTF8", "string"), and various character encoding conversions can be implemented.

http://www.bkjia.com/PHPjc/632448.html www.bkjia.com true http://www.bkjia.com/PHPjc/632448.html techarticle I didn't learn PHP before, and I decided to learn to do PHP while I was working on a project. 1 in an SQL statement, you can add a constraint by adding: Left (text,20) takes only the first 20 words of text;

  • 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.