PHP basename () ฟังก์ชัน
ความหมายและการใช้งาน
basename () ฟังก์ชันส่งกลับส่วนเส้นทางของชื่อไฟล์
ไวยากรณ์
basename(path,suffix)
参数 | 描述 |
---|---|
path | 必需。规定要检查的路径。 |
suffix | 可选。规定文件扩展名。如果文件有名有文件扩展名,将不会显示这个扩展名。 |
ตัวอย่าง
<?php
$path = "/testweb/home.php";
//Show filename with file extension
echo basename($path) ."<br/>";
//Show filename without file extension
echo basename($path,".php");
?>
$path = "/testweb/home.php";
//Show filename with file extension
echo basename($path) ."<br/>";
//Show filename without file extension
echo basename($path,".php");
?>
รหัสข้างต้นส่งออกจะ:
home.php
home
home
เสร็จสมบูรณ์คู่มือการใช้งานระบบแฟ้ม PHP อ้างอิง