![]() | การพัฒนาโปรแกรมด้วย PHP | ![]() |
| หน่วยที่ 7. การพัฒนาโปรแกรมด้วย PHP _ _ _ [ menu ] | |
1. สามารถติดตั้งโปรแกรมเพื่อใช้พัฒนาภาษา PHP ได้ 2. สามารถอธิบายลักษณะต่าง ๆ ของภาษา PHP ได้ 3. สามารถเขียนโปรแกรมด้วยภาษา PHP ได้ |
1. 2. |
7.1 ความรู้เบื้องต้นเกี่ยวกับภาษา 7.2 การติดตั้งเครื่องบริการ เพื่อบริการ PHP 7.3 การโปรแกรมโครงสร้าง 7.4 การรับ และส่งข้อมูล 7.5 การเขียนโปรแกรมใช้งานอย่างง่าย |
1. http://www.thaiall.com/php 2. http://www.php.net 3. http://www.thaiall.com/webserver 4. http://www.thaiall.com/mysql แบบฝึกหัดท้ายบท 1. เขียนตัวอย่างโปรแกรมด้านล่างนี้สัก 5 รอบ 2. 3. |
ตัวอย่างแฟ้ม a.php ที่สร้างขึ้นด้วย notepad
<html>
<head><title>hello</title></head>
<body>
<?
echo "hello, kim heesun";
?>
</body>
</html>
หรือ แฟ้ม b.php
<?
echo "<html><body>";
echo "hello, kim heesun";
echo "</body></html>";
?>
หรือ แฟ้ม c.php
<body>
<form action=x.php method=get>
<input name=web size=40><br>
<input type=submit>
</form>
<?
echo "<a href=" . $_GET['web'] . ">" . $_GET['web'] . "</a>";
?>
</body>
หรือ แฟ้ม d.php :: อ่านข้อมูลจาก mysql มาแสดงผล
<?
$host = "localhost";
$db = "test";
$tb = "cust";
$user = "root";
$password = "yourpassword";
$query = "select * from $tb";
###########################
$connect = mysql_connect("$host","$user","$password");
$result = mysql_db_query($db,$query);
if ($result) echo "OK<br>"; else exit;
while ($object = mysql_fetch_object($result)) {
foreach ($object as $o) echo $o;
echo "<br>";
}
mysql_close($connect);
?>