Passing variables to a PHP include file

Written by:
Last updated: May 1, 2025

Sadly, this just isn\’t possible. You would think you would be able to do the following:

[source: php]

include (“filename.php?variable=123”);
[/source]
But you just can\’t. There is an alternative though. You can set the variable just before you include the file, for example:

[source: php]

$variable=123;
include (“filename.php”);
[/source]