PHP string and connection database basic knowledge points

Source: Internet
Author: User

<?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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.