PHP Include

I have an included file that is not reading the variable from the calling php. The variable is always null. How can I send a variable to the include file? I have to declare the variable in main.php.

Example:

Main.php

$Value=“Hey”;
include ’ resources/Content.php’;

Content.php
echo $Value;

You need to include main.php in content.php or use sessions.

You don’t need sessions for this. It should work as is. Are you sure Content.php is being included? I notice some extra whitespace there.

Try something like [php]echo "Value is: ".$value;[/php] to debug.

Sponsor our Newsletter | Privacy Policy | Terms of Service