ฟังก์ชั่น chdir()
ความหมายของฟังก์ชั่นและการใช้งาน
การเปลี่ยน directory ปัจจุบันที่กำลังใช้งานอยู่ ( เปลี่ยน path ของไฟล์ที่ใช้งานอยู่ ) ด้วยฟังก์ชั่น chdir()
รูปแบบการเขียน (Syntax)
- ถ้าเปลี่ยนสำเร็จจะคืนค่า true กลับมา และจะคืนค่า false ถ้าเปลี่ยนไม่สำเร็จ
bool chdir ( string $directory )
ตัวอย่างที่ 1
<?php
// current directory
echo getcwd() . "\n";
chdir('public_html');
// current directory
echo getcwd() . "\n";
?>
Output :
/home/vincent
/home/vincent/public_html