Skip to content

Chapter 37 of 38

PHP 7 and 8 Runtime Features

Understand OPcache, JIT, attributes, enums, match, and version compatibility.

38 minutes 10 quick checksBy Subha Prasad
Lesson 37 of 38Course navigation

Lesson content

Read, practise, then check your understanding

OPcache stores compiled opcodes across requests and usually matters more to web workloads than JIT. JIT compiles eligible code to machine code but does not accelerate network/database waiting.

Practical example

<?php
#[Attribute(Attribute::TARGET_METHOD)]
final class Route { public function __construct(public string $path) {} }
enum Status: string { case Draft = 'draft'; case Published = 'published'; }

Attributes provide native metadata; enums model closed case sets; match and readonly features strengthen domain code. Benchmark JIT on representative CPU-heavy workloads. Declare a minimum PHP version, monitor deprecations, and upgrade dependencies before runtime transitions.

Knowledge check

Answer every question correctly to complete this chapter.

Which statement best describes JIT?
Which PHP term matches this description: Optional runtime compilation of eligible PHP code to machine code.
Which statement best describes OPcache?
Which PHP term matches this description: Shared caching of compiled PHP opcodes across requests.
Which statement best describes attributes?
Which PHP term matches this description: Native structured metadata attached to declarations.
Which statement best describes enum?
Which PHP term matches this description: A closed set of named cases introduced in PHP 8.1.
Which statement best describes match?
Which PHP term matches this description: A strict expression-based alternative to many switch uses.

0 of 10 checks passed

Your progress is saved on this device.