From the perspective of experiences, php + mysql provides solid basic skills-PHP Tutorial

Source: Internet
Author: User
From the perspective of experiences, php and mysql have solid basic skills. I. 10 sentences 1. do not rely on the register_globalON environment. from the day when you know how to configure the php runtime environment or even do not understand the impact of register_global ONOFF on yourself, you should. 10 sentences
1. do not rely ON the register_global = ON environment. from the day when you have just learned how to configure the php runtime environment and even do not understand the impact of register_global ON/off on yourself, we should be brave enough to set it to OFF.
2. check how to use error_reporting before writing a program.
3. if you don't understand it, you are right. but you need to check the manual before that.
4. of course, you need to understand the user manual. When you cannot find the answer in the manual, you should consider the search engine on the network.
5. after learning php + mysql, do not yell at writing forum or XXX. To understand, just learning to write Chinese characters does not mean that you have the ability to write poems.
6. when learning web programming, you should first meet the html friend.
7. if you have some skills, try to answer questions from new users. Don't be complacent if you don't know what you understand. if you drop a "simple, it's a basic thing", you have to go.
8. thinking is a good habit. if you do not write it, you are just a fantasy. there is nothing.
9. write a program. if you are satisfied, read it again in a week, you may think it should be changed.
10. if you have time, look at other people's programs to find out their own shortcomings or advantages.
II. different requirements

1. good at using "reference", which can directly affect the efficiency of the program.

2. be good at using a trielement operator to make the program simpler and more efficient.
For example:

PHP code :--------------------------------------------------------------------------------
If ($ data [$ I] ['nickname'])
{
$ Nickname = $ data [$ I] ['nickname'];
}
Else
{
$ Nickname = $ data [$ I] ['IP'];
}

--------------------------------------------------------------------------------

Can be written:

PHP code :--------------------------------------------------------------------------------
$ Nickname = $ data [$ I] ['nickname']? $ Data [$ I] ['nickname']: $ data [$ I] ['IP'];

--------------------------------------------------------------------------------


3. be good at organizing if... else... loop
For example:

PHP code :--------------------------------------------------------------------------------
$ Ext_name = strtolower (str_replace (".", "", strrchr ($ upfilename ,".")));
If (! Empty ($ type ))
{
If (! Strpos ($ type, $ ext_name ))
{
Echo "Please upload the file of $ type form .";
Exit ();
}
}

--------------------------------------------------------------------------------

The above code should be written as follows:

PHP code :--------------------------------------------------------------------------------
$ Ext_name = strtolower (str_replace (".", "", strrchr ($ upfilename ,".")));
If (! ($ Type = '') & strpos ($ type, $ ext_name) = false)
{
Echo "Please upload the file of $ type form .";
Exit ();
}

--------------------------------------------------------------------------------


4. try to clear your code
If it is written like this, it is a headache:

PHP code :--------------------------------------------------------------------------------
$ Foo = $ _ post ["foo"];
$ Username = $ _ post ["user"];
$ Group = $ _ POST ["group"];
If ($ group = "wheel "){
$ Username = $ username. "wheel ";
}

--------------------------------------------------------------------------------

The same code makes it easy to see:

PHP code :--------------------------------------------------------------------------------
$ Foo = $ _ post ["foo"];
$ Username = $ _ post ["username"];
$ Group = $ _ POST ["group"];
If ($ group = "wheel ")
{
$ Username = $ username. "wheel ";
}

--------------------------------------------------------------------------------

Of course, you should write it as follows:

PHP code :--------------------------------------------------------------------------------
$ Foo = & $ _ POST ['foo'];
$ Username = $ _ POST ["group"]! = 'Wheel '? $ _ POST ["username"]: $ _ POST ["username"]. 'wheel ';

--------------------------------------------------------------------------------

5. write a standard mysql statement.
Fields and table names are caused by "'" to avoid the impact of reserved words.
If you see the following SQL query, it will be a headache:

PHP code :--------------------------------------------------------------------------------
$ Query = "select 'flash _ comment '. 'content', 'Flash _ comment '. 'nickname', 'Flash _ comment '. 'date', 'Flash _ comment '. 'IP', 'product '. 'P _ name', 'sgflash '. 'fid' from 'flash _ comment' left join 'product' on ('flash _ comment '. 'P _ no' = 'product '. 'P _ no') left join 'sgflash' on ('product '. 'P _ name' = 'sgflash '. 'F _ name') where 'flash _ comment '. 'P _ no '! = ''Order by 'flash _ comment '. 'date '";

--------------------------------------------------------------------------------

The same query can be written as follows:

PHP code :--------------------------------------------------------------------------------
$ Query = "Select 'flash _ comment '. 'content', 'Flash _ comment '. 'nickname', 'Flash _ comment '. 'date', 'Flash _ comment '. 'IP', 'product '. 'P _ name', 'sgflash '. 'fid'
FROM 'flash _ comment'
Left join 'product' ON ('flash _ comment '. 'P _ no' = 'product'. 'P _ no ')
Left join 'sgflash 'ON ('product'. 'P _ name' = 'sgflash'. 'F _ name ')
Where 'flash _ comment'. 'P _ no '! =''
OrDER BY 'flash _ comment'. 'date '";

--------------------------------------------------------------------------------


//
.....

Lifecycle 1. do not rely ON the register_global = ON environment. from the day when you just learned how to configure the php runtime environment and even do not understand the impact of register_global ON/off on yourself, you should...

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.