The difference between single quotes ' and double quotes ':
The first is that single quotes are more efficient than double quotes, because the double quotes preprocess the content.
For example: ' $value ' output character $value; The value of the "$value" Output variable $value.
The difference between char and varchar:
Char is fixed length and varchar is variable length, the main feature of Char is the storage method pre-allocation, varchar when its data length changes, it will affect its stored page allocation.
Char and VARCHAR2 are a pair of contradictory unity, the two are complementary relations.
VARCHAR2 saves space than Char and is slightly less efficient than char, that is, to be efficient, you have to sacrifice a certain amount of space, which is what we often call "space-for-efficiency" in database design.
Although VARCHAR2 is more space-saving than char, if a VARCHAR2 column is often modified and the length of each modified data is different, this causes a ' row-migration ' phenomenon, which creates redundant I/O, which is to be avoided in database design and tuning. , it would be better to use char instead of VARCHAR2 in this case.
The difference between mysql_connect and Mysql_pconnect
Quote a friend on the Exceed PHP Club forum:
How to implement Mysql_pconnect () in PHP:
In fact, Mysql_pconnect () itself did not do too much processing, the only thing it does is to not actively close the MySQL connection after the end of the PHP run.
Mysql_pconnect () at the same time the difference between mysql_connect ():
CGI mode:
Pconnect and connect are basically no different when PHP is running CGI, because the CGI approach is a process that each PHP accesses, and the process ends after the visit, and the resources are all released.
Apache Module Mode:
The difference is that when PHP is running as an Apache module, because Apache has a process pool, a httpd process is put back into the process pool, which makes the MySQL connection resource opened with Pconnect not be freed, so there is the next connection request that can be reused.
This makes the time when the Apache concurrent access volume is not large, because of the use of Pconnect, PHP saves a number of times to connect to the DB, resulting in faster access. This should be better understood.
However, when the Apache concurrent access is large, if you use Pconnect, because some of the previous httpd processes occupy the MySQL connection is not close, it may be because MySQL has reached the maximum connection, so that some subsequent requests will never be satisfied.
For example:
If the maximum number of MySQL connections is set to 500, and Apache has the maximum number of simultaneous accesses set to 2000
Assuming all accesses require access to the DB, and the operation time is longer
The httpd of the current 500 requests is not at the end of the time ... Subsequent HTTD processes are unable to connect to MySQL (due to the maximum number of MySQL connections already reached). MySQL can be connected only if the current 500 httpd processes are terminated or reused.
In fact, this is also very good to explain the xgy_p test if the operation is relatively simple, pconnect than connect efficiency is much higher, and with the use of JSP connection pool speed is relatively close. Because this time the httpd process can be reused continuously.
When the DB operation is complex and takes a long time, because httpd will fork many concurrent processes, and the first generation of the httpd process does not release the DB connection, so that the resulting httpd process can not connect to the DB. Because this does not re-use the MySQL connection of the other httpd process. So there is a lot of connection timeouts, like the first 1000 concurrent connection tests that almost all connect timeouts are the reason.
---
(To see if the JSP uses a pure DB connection pool, there will be no problem due to reach the MySQL connection limit, because the JSP connection pool will make it possible to wait for other connections to be completed and reused.)
Therefore, when the concurrent traffic is not high, the use of pconnect can simply improve the access speed, but after the increase in concurrency, whether to use the pconnect will see the programmer's choice.
In my opinion, PHP is now connected to MySQL does not really use the connection pool, Pconnect is only equivalent to borrow the Apache process pools, so when the concurrent traffic is large pconnect does not improve the efficiency of access to the DB. At this point. PHP does not compare with JSP.
In this case, if the concurrency is large, I personally suggest that it is better to use mysql_connect.
The difference between include and require
The following are taken from phpchina.cn
PHP's require () performance is similar to include (). The difference is that, for the include (), the file is read and evaluated every time the include () is executed, and for require (), the file is processed only once (in fact, the file contents replace the Require () statement). This means that if you have code that contains one of these directives and code that might execute multiple times, using require () is a high efficiency. On the other hand, if you read a different file each time you execute the code, or you have a loop that iterates through a set of files, you use include () because you can set a variable for the file name you want to include, and use that variable when the parameter is include ().
The include does not stop immediately if the include file is in error, and require terminates the program immediately and does not go down.
Include can be used in loops; require not.
The following are taken from Ricky
1,require is an unconditional inclusion, that is, if a process joins require, it will be executed first, whether or not the condition is established require
This is no longer applicable because require can contain variables that point to files such as
if ($a = 1) {
$file = ' 1.php ';
}else{
$file = ' 2.php ';
}
Require ($file);
2, contains the file does not exist or syntax error when require is fatal, include is not
3,include has a return value, and require does not (possibly because it is so require faster than include)
$login = include (' test.php ');
if (!empty ($login)) {
echo "file contains success";
}else{
echo "file contains failed";
}
There are two ways to refer to a file: Require and include. Two ways to provide different use elasticity.
Require use methods such as require ("myrequirefile.php");. This function is usually placed at the front of the PHP program, and before the PHP program executes, it is read into the file specified by require to make it a part of the PHP program's Web page. Commonly used functions, you can also use this method to introduce it into the Web page.
Include usage methods such as include ("myincludefile.php");. This function is usually placed in the processing part of the process control. The PHP Program page reads the include file before it is read in. This way, you can simplify the process when the program executes.
The difference between isset () and Empty ()
Both are test variables, but Isset () is the test variable is assigned, and empty () is the test of whether a variable that has been assigned is empty.
If a variable is not assigned to the reference in PHP is allowed, but there will be notice hint, if a variable is assigned a null value, $foo = "" or $foo=0 or $foo =false, then empty ($foo) return True, Isset ($foo) also return True, This means that a null value does not unregister a variable.
To unregister a variable, you can use Unset ($foo) or $foo=null
The above on the introduction of Kung fu is not negative what the meaning of the small difference php some interesting, including the kung fu is not negative what the meaning of the content, I hope that the PHP tutorial interested in a friend helpful.