Experience Talking about PHP + MYSQL Solid Personal Basics

xiaoxiao2021-03-06  54

The experience of the family is talking about PHP MYSQL solid personal basic skills. 10 words 1. Do not rely on the environment of register_global = ON, from you just know how to configure the PHP running environment, even don't understand what REGISTER_GLOBAL will have any impact on himself It should be set up to OFF.2 on that day. Don't understand how to use error_reporting.3 before writing the program. Don't understand it, but you need to check the manual before that. 4. Of course, you need to know how to use the manual. When you can't find an answer on your manual, you should consider the search engine on your network. 5. After learning the PHP MySQL, don't call the Forum and write xxx. To understand, just learn to write Chinese characters does not mean that you have the ability to write poetry. 6. When learning Web programming, you should first know the html friend. 7. After a little ability, try to answer a novice problem, don't see you know what you know, don't understand, you will be self-satisfied, throw a "simple, that is the basic thing". 8. Thinking is a good habit, you don't move your hand, you will wait for the empty ideas, and there is no. 9. Write a program, if you feel very satisfied, look at it again, maybe you will think that it should change 10. There are free to see someone else's procedures, find out the insufficient or advantages of others, you can quasi. II. Each takes the required 1. Good at "reference", which can directly affect the efficiency of the program. 2. Be good at using the three-yuan operator, allowing the process to be more efficient. such as:

Code: [Copy to CLIPBOARD]

IF ($ DATA [$ I]) {$ nickname = $ data [$ I] ['nickname'];} else {$ nickname = $ data [$ i] ['ip'];}

Can be written:

Code: [Copy to CLIPBOARD]

$ nickname = $ data [$ I] ['Nickname']? $ data [$ I] ['Nickname']: $ DATA [$ I] ['ip'];

3. Good at tissue IF ... Else ... Back to ring, for example:

Code: [Copy to CLIPBOARD]

$ ext_name = strtolower (str_replace (",", strrchr ($ upfilename, ")))); if (! EMPTY) {if (! Strpos ($ TYPOS ($ TYPOS ($ ext_name) {echo "Please Upload the file of $ type form."; exit ();}}

You should write this:

Code: [Copy to CLIPBOARD]

$ ext_name = strtolower (str_replace (",", strrchr ($ upfilename, "))); if (! ($ type === ') && strpos ($ TYPO, $ ext_name) === False) {echo "please upgrad the file of $ type form."; exit ();

4. Try to let your code clearly write this, it is more headache:

Code: [Copy to CLIPBOARD]

$ foo = $ _ post ["foo"]; $ usrname = $ _ post ["user"]; $ group = $ _ post ["group"]; if ($ group == "WHEEL") {$ usrname = $ usrname. "Wheel";} The same code, this is more comfortable:

Code: [Copy to CLIPBOARD]

$ foo = $ _POST ["foo"]; $ usrname = $ _POST ["username"]; $ group = $ _POST ["group"]; if ($ group == "WHEEL") {$ username = $ usrname. "wheeel";

Of course, after a certain basis, you should be written:

Code: [Copy to CLIPBOARD]

$ foo = & $ _ post ['foo']; $ usrname = $ _POST ["group"]! = 'WHEEL'? $ _POST ["Username"]: $ _POST ["Username"]. 'Wheel';

5. Write a specified MySQL statement. Fields and table names use "` "to avoid the impact of reserving words. If you see a SQL Query below, people will compare headache:

Code: [Copy to CLIPBOARD]

$ query = "SELECT` Flash_comment`.`content`, `flash_comment`.`.` flash_comment`.date`, `flash_comment`.`.`,` sgflash`..` Fid` from `flash_comment` =` pROMENT`.````` = `sgflash`.` =` sgflash`. `=` sgflash`.`f_name `) WHERE` Flash_comment`.`p_no`! = '' Order by `flash_comment`.date`

The same Query, writing this way, it is much more clear:

Code: [Copy to CLIPBOARD]

转载请注明原文地址:https://www.9cbs.com/read-116489.html

New Post(0)