Hey!
I have a local test server on my machine and my production server.
Instead of constantly editing my database credentials I want to include a db.php file that looks like this:
<?php
var $hostt = "localhost";
var $db_database = "testdb";
var $db_username = "root";
var $db_password= "";
?>
but when I try including it like this:
<?php
class testme{
include_once "db.php";
...
It refuses to work and spits out:
Parse error: syntax error, unexpected T_INCLUDE_ONCE, expecting T_FUNCTION in
How can I get it to work the way I want to? Is it possible or am I barking up the wrong tree?
Thanks!
R
You can’t execute an include statement outside of either the global scope or a function scope.
Move the include above your class declaration.
If you need access to those configuration options inside your class, try something like this.
If you need it from many functions within the class. Set a class variable within your constructor: