imagefontheight() เป็นฟังก์ชันในตัวของ PHP ที่ใช้เพื่อรับความสูงในหน่วยพิกเซลของตัวอักษรในแบบอักษรที่ระบุ
รูปแบบการใช้งาน (Syntax)
int imagefontheight(int $font)
พารามิเตอร์
imagefontheight() รับพารามิเตอร์เดียวคือ $font ซึ่งเก็บค่าแบบอักษร ค่า $font สามารถเป็น 1, 2, 3, 4, และ 5 สำหรับแบบอักษรในตัว (built-in fonts) หรือสามารถใช้กับแบบอักษรที่กำหนดเองผ่านฟังก์ชัน imageloadfont()
ค่าที่คืนกลับ (Return Values)
imagefontheight() จะคืนค่าความสูงของแบบอักษรในหน่วยพิกเซล
ตัวอย่างที่ 1
<?php // ค่าความสูงแบบอักษรสามารถเปลี่ยนได้จาก 1 ถึง 5 echo 'Font height: ' . imagefontheight(3); ?>
ผลลัพธ์
Font height: 13
ตัวอย่างที่ 2
<?php // รับความสูงแบบอักษรจาก 1 ถึง 5 echo 'Font height for the font value 1 is ' . imagefontheight(1) . '<br>'; echo 'Font height for the font value 2 is ' . imagefontheight(2) . '<br>'; echo 'Font height for the font value 3 is ' . imagefontheight(3) . '<br>'; echo 'Font height for the font value 4 is ' . imagefontheight(4) . '<br>'; echo 'Font height for the font value 5 is ' . imagefontheight(5) . '<br>'; ?>
ผลลัพธ์
Font height for the font value 1 is 8 Font height for the font value 2 is 13 Font height for the font value 3 is 13 Font height for the font value 4 is 16 Font height for the font value 5 is 15