[Reserved] The experience of a family is talking about PHP + MYSQL solid personal basic skills

zhaozj2021-02-16  78

I. 10 sentences 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 that regis Ter_Global's on / off will have any effect on what you have, you should be brave. To OFF. 2. See how to use error_reporting before writing the program. 3. If you don't understand, ask it it's right, but you need to check the manual before. 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 and do not show you 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. For example: PHP code: --------------------------------------------- ----------------------------------

IF ($ DATA [$ I]) {$ 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. Good at tissue IF ... Else ... round circle

such as:

PHP code: ----------------------------------------------- -----------------------

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

$ 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:

PHP code: ----------------------------------------------- ---------------------------------

$ 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 make your code clear

If you write this, it is more headache:

PHP code: ----------------------------------------------- -----------------------

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

$ foo = $ _ post ["foo"]; $ usrname = $ _ post ["user"]; $ group = $ _ post ["group"]; if ($ group == "WHEEL") {$ usrname = $ usrname. "wheeel";

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

-

The same code, this is more comfortable:

PHP code: ----------------------------------------------- -----------------------

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

$ 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:

PHP code: ----------------------------------------------- -----------------------

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

$ 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:

PHP code: ----------------------------------------------- ---------------------------------

$ query = "SELECT` Flash_comment`.`content`, `flash_comment`.`.,` flash_comment`.`date`, `flatuct`.``.`.` sgflash`. `fid` from` Flash_comment` `````.`.`.`.`. `sgflash` =` pROMMENT`.`````` `f_name`) WHERE` Flash_comment`.`p_no`! = '' ORDER BY `Flash_Comment`.date`

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

-

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

PHP code: ----------------------------------------------- -----------------------

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

$ query = "SELECT` Flash_Comment`.`content`, `flash_comment`..`.` flash_comment`.date`, `flatuct`.`.`.` sgflash`. `fi d` from` flash_comment` l```. ``. ``.`.`.`.``` = `.``` =` sgflash`.. = `sgflash`. `f_name`) WHERE` Flash_comment`.`p_no`! = '' ORDER BY `Flash_Comment`.date`

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

-

//

.....

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

New Post(0)