@require - Include PHP Files
The @require
directive in Ahmed PHP Template Engine allows you to include an external PHP file within your template.
Syntax
filePath
: The path to the PHP file relative to the project directory.
Description
This directive loads and executes a PHP file within the template.
Useful for reusing code, importing functions, or loading configuration files.
If the file is missing, an error will be triggered.
Example
Assuming header.php
contains:
You can use:
Expected Output
Notes
The included file is executed in the current template scope.
Ensure the file exists to avoid errors.
Unlike
@include
,@require
will stop execution if the file is not found.
Last updated