1: Defining Constants
Define ("HOST", "127.0.0.1");
Define ("USER", "rooot"); Database User
Define ("PWD", "root"); Password
$conn = "";
function Get_coon () {
Global $conn;
$conn = mysql_connect (host,user,pwd) or Die (Mysql_error ());
mysql_select_db ($db, $conn);
mysql_query ("Set names ' UTF8 '");
}
function query ($sql) {
$result = mysql_query ($sql);
$r = Array (); declares an empty array
while ($row = Mysql_fetch_array ($result)) {
$r [] = $row;
without a loop , pass the $row to $rso that$r An automatically numbered two-dimensional array
}
Return $r;
}
Insert Method
function Insert ($sql) {
$result = mysql_query ($sql);
return $result;
}
function Close () {
Global%conn;
Mysql_close ($conn);
}
2: Call
<?php
Include ("dbhelper.php");
Get_conn ();
$r = Query ("Select *from users");
foreach ($r as $row) {
?>
<?php
}
?>
(2):Function Text1 ($str 1, $str 2) {
to split an array into strings
The following method means that$str 2 should be an array
and then divide the array into a new string, as well.
$SL = Implode (".". $str 2);
Echo "$SL";
splitting a string into an array explode
This function means that first $str 1 is a string that is assembled according to a specification.
This specification is a style that must conform to the first parameter above
$tr 2 = Explode ("-", $str 1);
Print_r ($s 2);
}
(3):Substr
(4):vsprintf ("%d-%d-%d", array );
gets an array of all arguments passed in
Cases:
$arr = [A]
Echo vsprintf ("%d-%d-%d", $arr);
(5):%d(array type) equals placeholder
%s(character type)
//
Func_num_args ();
get function All parameters
Func_get_args ();
(6):str_replace ("", "", ");
(7) Str_replace ();
(8) Array_shift ();
(9) Var_dump ();