PHP include problem

software development

#1

Hello
I have a problem like the following:

index.php

<?php $check =1; include_once('include.php'); ?>

include.php

<?php if ($check <> 1) ... else ... ?>

The problem is $check is always empty.
I cannot pass check variable value from index.php to the included file include.php.
kindly may you tell where is the mistake ?
do i have to change my php.ini or .htaccess setup ?
tks a lot in advance for assistance.


#2

index.php

<?php define("check",1); include_once('include.php'); ?>include.php

<?php if(defined("check")) { ... } else { ... } ?>
Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

If you’re access to the $check variable in include.php is inside a function you can define it as “global” inside the function:

function test ()
{
global $check;

if ($check == 1)
{
echo “yes”;
}
}