# PHP สมัยใหม่ (8.1+) (Symfony) > Enums, readonly properties, attributes, promoted properties, named arguments, union types, การกำหนดชนิดข้อมูลแบบเข้มงวด, match expression - 20 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions.md) ## 1. ไวยากรณ์ที่ถูกต้องในการประกาศ enumeration (enum) ใน PHP 8.1+ คืออะไร? **คำตอบ** ใน PHP 8.1+ การประกาศ enumeration ใช้คีย์เวิร์ด enum ตามด้วยชื่อและ case ที่เป็นไปได้ภายในวงเล็บปีกกา enums ช่วยให้กำหนดชนิดข้อมูลที่มีชุดของค่าที่เป็นไปได้แบบจำกัด ซึ่งช่วยเพิ่มความปลอดภัยของชนิดข้อมูลและทำให้โค้ดสื่อความหมายได้ดีขึ้น backed enums สามารถมีค่า string หรือ int ที่เกี่ยวข้องได้ ## 2. Backed enum ใน PHP 8.1+ คืออะไร? **คำตอบ** Backed enum คือ enumeration ที่แต่ละ case เชื่อมโยงกับค่าสเกลาร์ (string หรือ int) ค่านี้ช่วยให้สามารถทำ serialization และจัดเก็บในฐานข้อมูลได้ ไวยากรณ์ใช้เครื่องหมายทวิภาคหลังชื่อ enum เพื่อระบุชนิดของ backing จากนั้นแต่ละ case จะได้รับค่าด้วยเครื่องหมายเท่ากับ ## 3. จะประกาศพร็อพเพอร์ตี readonly ใน PHP 8.1+ ได้อย่างไร? **คำตอบ** ตัวขยาย readonly จะวางไว้ก่อนชนิดของพร็อพเพอร์ตี พร็อพเพอร์ตี readonly สามารถกำหนดค่าเริ่มต้นได้เพียงครั้งเดียวเท่านั้น ไม่ว่าจะในการประกาศหรือในคอนสตรักเตอร์ เมื่อกำหนดแล้วจะไม่สามารถเปลี่ยนค่าได้ ซึ่งรับประกันความไม่เปลี่ยนแปลงของพร็อพเพอร์ตีนั้น ## มีอีก 17 คำถาม - ข้อจำกัดหลักของพร็อพเพอร์ตี readonly ใน PHP 8.1+ คืออะไร? - Constructor property promotion ใน PHP 8.0+ คืออะไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Symfony อื่นๆ - [พื้นฐาน Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/symfony-basics.md): 25 คำถาม, Junior - [Routing & Controllers](https://sharpskill.dev/th/technologies/symfony/interview-questions/routing-controllers.md): 20 คำถาม, Junior - [Twig & Templates](https://sharpskill.dev/th/technologies/symfony/interview-questions/twig-templates.md): 20 คำถาม, Junior - [พื้นฐาน Doctrine ORM](https://sharpskill.dev/th/technologies/symfony/interview-questions/doctrine-orm-basics.md): 25 คำถาม, Junior - [ฟอร์ม Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/forms.md): 22 คำถาม, Junior - [การตรวจสอบความถูกต้องของข้อมูล](https://sharpskill.dev/th/technologies/symfony/interview-questions/validation.md): 18 คำถาม, Junior - [Dependency Injection & Services](https://sharpskill.dev/th/technologies/symfony/interview-questions/dependency-injection.md): 24 คำถาม, Mid-Level - [Security & Authentication](https://sharpskill.dev/th/technologies/symfony/interview-questions/security-authentication.md): 26 คำถาม, Mid-Level - [Doctrine ขั้นสูง](https://sharpskill.dev/th/technologies/symfony/interview-questions/doctrine-advanced.md): 24 คำถาม, Mid-Level - [API Platform](https://sharpskill.dev/th/technologies/symfony/interview-questions/api-platform.md): 22 คำถาม, Mid-Level - [Serializer Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/serializer.md): 20 คำถาม, Mid-Level - [Events & Event Subscribers](https://sharpskill.dev/th/technologies/symfony/interview-questions/events-subscribers.md): 20 คำถาม, Mid-Level - [Console & Commands](https://sharpskill.dev/th/technologies/symfony/interview-questions/console-commands.md): 18 คำถาม, Mid-Level - [Messenger Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/messenger.md): 22 คำถาม, Mid-Level - [HTTP Client](https://sharpskill.dev/th/technologies/symfony/interview-questions/http-client.md): 18 คำถาม, Mid-Level - [Cache & ประสิทธิภาพ](https://sharpskill.dev/th/technologies/symfony/interview-questions/cache.md): 20 คำถาม, Mid-Level - [Workflow Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/workflow.md): 18 คำถาม, Mid-Level - [Testing Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/testing.md): 22 คำถาม, Mid-Level - [Mailer Component](https://sharpskill.dev/th/technologies/symfony/interview-questions/mailer.md): 16 คำถาม, Mid-Level - [การแปลและ i18n](https://sharpskill.dev/th/technologies/symfony/interview-questions/translations.md): 16 คำถาม, Mid-Level - [EasyAdmin Bundle](https://sharpskill.dev/th/technologies/symfony/interview-questions/easyadmin.md): 18 คำถาม, Mid-Level - [สถาปัตยกรรม Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/architecture-patterns.md): 24 คำถาม, Senior - [ประสิทธิภาพและการเพิ่มประสิทธิภาพ](https://sharpskill.dev/th/technologies/symfony/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [ความปลอดภัยขั้นสูง](https://sharpskill.dev/th/technologies/symfony/interview-questions/security-advanced.md): 22 คำถาม, Senior - [Custom Bundles](https://sharpskill.dev/th/technologies/symfony/interview-questions/custom-bundles.md): 20 คำถาม, Senior - [Microservices ด้วย Symfony](https://sharpskill.dev/th/technologies/symfony/interview-questions/microservices.md): 22 คำถาม, Senior - [Real-time & WebSockets](https://sharpskill.dev/th/technologies/symfony/interview-questions/real-time.md): 18 คำถาม, Senior - [Deployment & DevOps](https://sharpskill.dev/th/technologies/symfony/interview-questions/deployment-devops.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/symfony/interview-questions/php-modern-features