switching from java to php, and have a scope question. If I have a couple of classes that look like this:
and I need to use them both in the same page, I'd use the require_once function to import both classes...
require_once('person.php');
require_once('user.php');
If both of these classes rely on a class called db_conn.php in order to connect to the database, then would I have to put require_once('db_conn.php'); in the page that is importing both of these classes, or could I put it in each of classes...
Thanks,
Greg
Code:
<?php
class Person{
//Some code that access the database
}
?>
<?php
class User{
//Some code that access the database
}
?>
and I need to use them both in the same page, I'd use the require_once function to import both classes...
require_once('person.php');
require_once('user.php');
If both of these classes rely on a class called db_conn.php in order to connect to the database, then would I have to put require_once('db_conn.php'); in the page that is importing both of these classes, or could I put it in each of classes...
Code:
<?php
require_once('db_conn.php');
class Person{
//Some code that access the database
}
?>
<?php
require_once('db_conn.php');
class User{
//Some code that access the database
}
?>
Thanks,
Greg