<?php$a1= "Hello", $a 2= "hell", Echo strlen ($a 1), Echo strcmp ($a 1, $a 2). " <br/> ";//Split string $str=" Hello|nihao|worde|name "; $arr 1=explode (" | ", $STR); Echo $arr 1[2]." <br/> ";///array to String $arr2=array (" One "," "", "" "", "" "," ""), "Echo Implode" ($arr 2). " ";//replace String, starting from a location to replace $th=substr_replace ($a 1," BB ", 0,2); Echo $th." <br/> ";//replacement string, the original character replaced by the new $s =" hello "; $a = Str_replace (" L "," a ", $s); Echo $a." <br/> ";//intercept string $jq=substr ($s, 0,3); echo $jq;//The position of the character in the string $s1=" Nihao "; Echo strpos ($s 1,h); $host = "localhost"; $uid = "root"; $pwd = "root"; $database = "Info"; $conn =mysql_connect ($host, $uid, $pwd); if ($conn ==false) {echo "Connection failed";} Else{echo "Connection succeeded";} mysql_select_db ($database, $conn); mysql_query ("CREATE Database Xuexi, $conn"); $result = mysql_query ("SELECT * from DL"); $ss = ""; while ($row =mysql_fetch_row ($result)) {$ss = $ss. $row [2]. " "; } Echo $ss; 1 Build Connection Object $db = new Mysqli ($host, $uid, $pwd, $database);//2. Determine if the connection is successful if (Mysqli_connect_error ()) {echo ' connection is missingDefeat! "; exit; Exit}//executes the MySQL statement $result= $db->query ("SELECT * from DL"), $zz = "<select>";//Iterate through the data in the array, do the drop-down menu while ($row = $result- >fetch_row ()/* Gets the return value, returns the array */) {$zz = $zz. " <option value= ' ". $row [1]." ' > ". $row [2]." </option> ";} $zz. " </select> "; Echo $zz;
PHP string and connection database basic knowledge points