I have a php file to create a directory. I want that php file execute in background. I have written 2 files like below.
file1.php
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
echo 'calling file1';
if(!is_dir('testdir')){
mkdir('testdir');
}
?>
index.php
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$i = '';
exec("php file1.php $i > test.txt &");
?>
I want a directory to be created when index.php is executed via browser. I think I am making mistake to write exec() function. Can anybody tell me how it will be?