phpstudy´î½¨ÍøÕ¾ÔõÑùÅþÁ¬ÍâµØÊý¾Ý¿â
ʹÓà php study ´î½¨ÍøÕ¾²¢ÅþÁ¬ÍâµØÊý¾Ý¿âÐèÒÔÏ°취£ºÅþÁ¬µ½Êý¾Ý¿âЧÀÍÆ÷£¨È·±£ mysql ЧÀÍÔËÐУ©£»½¨ÉèÊý¾Ý¿âºÍÓû§£¨ÊÚÓèËùÓÐȨÏÞ£©£»µ¼ÈëÊý¾Ý£¨¿ÉÑ¡£©£»ÔÚ php study ÖÐÉèÖÃÍøÕ¾£»ÔÚÍøÕ¾¸ùĿ¼½¨Éè php ÎļþÅþÁ¬Êý¾Ý¿â£»²âÊÔÅþÁ¬£¨ä¯ÀÀÆ÷»á¼ûÍøÕ¾£¬Ó¦ÏÔʾ¡°ÅþÁ¬Àֳɣ¡¡±£©¡£
ÔõÑùʹÓà PHP Study ´î½¨ÍøÕ¾²¢ÅþÁ¬µ½ÍâµØÊý¾Ý¿â
°ì·¨ 1£ºÅþÁ¬µ½Êý¾Ý¿âЧÀÍÆ÷
PHP Study ÄÚÖÃÁËÒ»¸ö MySQL ЧÀÍ£¬Ä¬È϶˿ںÅΪ 3306¡£·¿ª PHP Study ¿ØÖÆÃæ°å£¬È·±£ MySQL ЧÀÍÕýÔÚÔËÐС£
°ì·¨ 2£º½¨ÉèÊý¾Ý¿â
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÔÚ PHP Study ¿ØÖÆÃæ°åÖУ¬µ¥»÷¡°Êý¾Ý¿â¡±Ñ¡Ï£¬È»ºóµ¥»÷¡°+¡±°´Å¥½¨ÉèÐÂÊý¾Ý¿â¡£ÊäÈëÊý¾Ý¿âÃû³Æ²¢µ¥»÷¡°È·¶¨¡±¡£
°ì·¨ 3£º½¨ÉèÊý¾Ý¿âÓû§
µ¥»÷¡°Óû§¡±Ñ¡Ï£¬È»ºóµ¥»÷¡°+¡±°´Å¥½¨ÉèÐÂÓû§¡£ÊäÈëÓû§Ãû¡¢ÃÜÂëºÍÖ÷»ú£¨Í¨³£Îª¡°localhost¡±£©¡£È»ºóÑ¡ÖС°ÊÚÓèËùÓÐȨÏÞ¡±¸´Ñ¡¿ò£¬²¢µ¥»÷¡°È·¶¨¡±¡£
°ì·¨ 4£ºµ¼ÈëÊý¾Ý
ÈôÊÇÄúÒÑÓÐÊý¾Ý¿â±¸·Ý£¬¿ÉÒÔµ¥»÷¡°µ¼È롱°´Å¥²¢Ñ¡Ôñ±¸·ÝÎļþ¡£ÈôÊÇûÓб¸·Ý£¬Äú¿ÉÒÔÌø¹ý´Ë°ì·¨¡£
°ì·¨ 5£ºÉèÖà PHP ÍøÕ¾
ÔÚ PHP Study ¿ØÖÆÃæ°åÖУ¬µ¥»÷¡°ÍøÕ¾¡±Ñ¡Ï£¬È»ºóµ¥»÷¡°+¡±°´Å¥½¨ÉèÐÂÍøÕ¾¡£ÊäÈëÍøÕ¾¸ùĿ¼µÄ·¾¶¡£
°ì·¨ 6£ºÅþÁ¬µ½Êý¾Ý¿â
ÔÚÍøÕ¾¸ùĿ¼ÖУ¬½¨ÉèÒÔÏ PHP Îļþ£¨Èç database-connection.php£©£º
<?php // Êý¾Ý¿âÅþÁ¬²ÎÊý $servername = "localhost"; $username = "Êý¾Ý¿âÓû§Ãû"; $password = "Êý¾Ý¿âÃÜÂë"; $dbname = "Êý¾Ý¿âÃû³Æ"; // ½¨ÉèÅþÁ¬ $conn = mysqli_connect($servername, $username, $password, $dbname); // ¼ì²éÅþÁ¬ if (!$conn) { die("ÅþÁ¬Ê§°Ü£º" . mysqli_connect_error()); } echo "ÅþÁ¬Àֳɣ¡"; ?>
µÇ¼ºó¸´ÖÆ
°ì·¨ 7£º²âÊÔÅþÁ¬
·¿ªä¯ÀÀÆ÷²¢»á¼ûÍøÕ¾£¬Èç http://localhost/database-connection.php¡£ÈôÊÇÅþÁ¬Àֳɣ¬ÄúÓ¦¸Ã»á¿´µ½¡°ÅþÁ¬Àֳɣ¡¡±ÐÂÎÅ¡£
ÒÔÉϾÍÊÇphpstudy´î½¨ÍøÕ¾ÔõÑùÅþÁ¬ÍâµØÊý¾Ý¿âµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡