Execute the php file and collect the output

4 May 2016,
Share: 

ในบทความนี้ผมจะอธิบายวิธีการ Execte ไฟล์ php แล้วเอา output ไปใช้งานต่อ ตัวอย่างเช่น ถ้าเรามีไฟล์ cal.php สําหรับ ทําอะไรซักอย่าง แล้วเราต้องการจะเรียกใช้ไฟล์ดังกล่าวเพื่อเอาผลลัพธ์ไปใช้งาน เราจะสามารถเขียน code ได้ดังนี้

<?PHP
    ob_start();
    include "cal.php";
    $out = ob_get_clean();
?>

ผลลัพธิ์การ Execute ไฟล์ cal.php จะถูกเก็บในตัวแปร $out สามารถนําไปใช้ต่อได้เลย


Copyright © 2019 - 2025 thiti.dev |  v1.51.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ