Empty seems to be different from isset? See the following code & lt; html & gt; & lt; head & gt; & lt; metahttp-equiv & quot; content-type & quot; content & quot; texthtml; charsetutf-8 & quot; & gt; & lt; head & gt; & lt ;? What is the difference between php & nbsp; empty and isset? See the following code
// Display information of all users (table)
// Query data
$ Conn = mysql_connect ("localhost", "root", "5200") or die (mysql_error ());
// Sets the mysql encoding.
Mysql_query ("set names UTF-8", $ conn );
// Select a database
Mysql_select_db ("manage", $ conn) or die (mysql_error ());
$ PageSize = 3; // number of records per page
$ RowCount = 0;
If (! Empty ($ _ GET ['pagenow']) {
$ PageNow = 1;
}
Else {
$ PageNow = $ _ GET ['pagenow'];
}
$ SQL = "select count (id) from emp ";
$ Res1 = mysql_query ($ SQL );
If ($ row = mysql_fetch_row ($ res1 )){
$ RowCount = $ row [0]; // rowCount indicates the number of data records.
}
// Calculate the number of pages
$ PageCount = ceil ($ rowCount/$ pageSize );
$ SQL = "select * from emp limit". ($ pageNow-1) * $ pageSize. ", $ pageSize ";
$ Res2 = mysql_query ($ SQL, $ conn );
// $ SQL = "select * from emp ";
Echo "employee information table ";
Echo"
";Echo"
Id |
Name |
Grade |
Email |
Slary |
Modify user |
Delete a user |
";While ($ row = mysql_fetch_assoc ($ res2 )){Echo"
{$ Row ['id']} |
{$ Row ['name']} |
{$ Row ['grade ']} | "."
{$ Row ['email ']} |
{$ Row ['salary ']} | "."
Delete a user |
Modify user |
";}Echo"
";
// Print the page number hyperlink
For ($ I = 1; $ I <= $ pageCount; $ I ++)
{
Echo "$ I ";
}
?>
------ Solution --------------------
My friends often repeat
Bool empty (mixed $ var)
If var is a non-null or non-zero value, empty () returns FALSE. In other words, "", 0, "0", NULL, FALSE, array (), var $ var; and objects without any attributes will be considered empty, if var is null, TRUE is returned.
Bool isset (mixed $ var [, mixed $ var [, $...])
If var exists, TRUE is returned; otherwise, FALSE is returned.
If unset () is used to release a variable, it will no longer be isset (). If you use isset () to test a variable that is set to NULL, FALSE is returned. Note that a NULL byte ("\ 0") is not equivalent to the NULL constant of PHP.
------ Solution --------------------
PHP code
$ Str = 0; var_dump (empty ($ str); // truevar_dump (isset ($ str); // true
------ Solution --------------------
! Empty ($ x) = isset ($ x) & $ x
Empty ($ x) =! Isset ($ x) |! $ X