Syntax

PHP Include Another File Syntax

In PHP, include another file: loads another PHP file once — require_once 'config.php';

Quick Answer

Syntax
require_once 'config.php';
PHPSyntax

Include Another File

Code example
require_once 'config.php';

Loads another PHP file once.

Learn More

How to include another file in PHP

  1. Open your PHP file or editor.
  2. Copy the example, then replace its sample names and values for your code.

PHP Include Another File Syntax

Use require_once 'config.php';.

Related Syntax References

Frequently asked questions

What is the PHP syntax for include another file?

Use this pattern: require_once 'config.php';

Can I copy this PHP code example?

Yes. Use Copy code and adapt the example to your program.

Is this PHP syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify