I am using LAMP stack to develop a PHP application. I am using require_once to include class files. I need to use the functions in those class files in more than one PHP page. So, I am including those class files in all the required PHP pages using require_once. But, if I include those class files in more than one page, the PHP file goes blank. It displays nothing. View source also displays nothing.
Files: test.php, process.php and class.test.php
test.php has
<?php
session_start();
require_once 'classes/class.test.php';
.
Few more classes
.
.
?>
<html>
<form name = "myForm" method="POST" action="process.php">
<input type = "text" name="username" value=""/>
<input type = "submit" value="Submit" />
</form>
</html>
process.php
<?php
session_start();
require_once 'classes/class.test.php';
$obj_test = new test();
$obj_test->test();
?>
class.test.php
<?php
session_start();
require_once 'class.misc.php';
require_once 'config.php'; //DB connection details
function test()
{
$obj_misc = new misc();
$id = $obj_misc->random_ID();
$username = $_POST['username'];
$query = "INSERT INTO test_table VALUES ('$id','$username',NOW());
mysql_query($query);
}
?>
Now, it returns a blank page. If I comment out the require_once in process.php, the test.php page displays the form, but on submitting the form the process.php throws an error "class test not found".
I am struggling with this problem for the past 2 weeks. :( It was working fine before that. I don't understand what went wrong. Please help.