• March 13, 2023

    If you include a file into another file, the code in the included file will be treated as if it was written directly in the file that includes it.

    So if the included file contains any functions, variables, or classes that are needed in the including file, they will be available in the including file as well.

    Including a file can be a useful way to organize your code into smaller, more manageable chunks, and to reuse code across multiple files. However, it’s important to make sure that the included file is well-written and doesn’t cause any conflicts or unexpected behavior when included in other files.

    หากคุณรวมไฟล์ไว้ในไฟล์อื่น โค้ดในไฟล์ที่รวมจะถือว่าเหมือนกับว่าเขียนโดยตรงในไฟล์ที่มีไฟล์นั้น

    ดังนั้นหากไฟล์ที่รวมมีฟังก์ชัน ตัวแปร หรือคลาสใดๆ ที่จำเป็นในไฟล์ที่รวม ก็จะพร้อมใช้งานในไฟล์ที่รวมด้วยเช่นกัน

    การรวมไฟล์อาจเป็นวิธีที่มีประโยชน์ในการจัดระเบียบโค้ดของคุณให้มีขนาดเล็กลงและจัดการได้มากขึ้น และใช้โค้ดซ้ำกับหลายๆ ไฟล์ อย่างไรก็ตาม สิ่งสำคัญคือต้องแน่ใจว่าไฟล์ที่รวมนั้นเขียนได้ดี และไม่ก่อให้เกิดความขัดแย้งหรือลักษณะการทำงานที่ไม่คาดคิดเมื่อรวมอยู่ในไฟล์อื่นๆ

    การ include form เข้ามาในไฟล์
    แก้โดยใส่
    session_start();

    ในไฟล์ footer.php , menu.php



เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories


Uncategorized