@require - Include PHP Files

The @require directive in Ahmed PHP Template Engine allows you to include an external PHP file within your template.

Syntax

@require(filePath)
  • 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:

<h1>Welcome to Ahmed Engine</h1>

You can use:

@require("header.php")

<p>Main content goes here.</p>

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