Possible Duplicate:
declare property as object?
Why don't PHP attributes allow functions?
I'm trying to replicate the idea inspired by .NET's web.config
by storing connection strings in an XML document.
but the problem is I keep getting an error everytime I try to load my XML file in the my class that would handle the database connectivity.
for example I have this XML markup:
connections.xml
<?xml version="1.0" encoding="UTF-8" ?>
<connections>
<connection name="MyConnection"
connectionstring="mysql:host=localhost;dbname=MyDatabase"
username="username"
password="password" />
</connections>
and the PHP class that would handle it.
Connection.php
<?php
class Connection {
// I keep getting errors here
protected $xml = simplexml_load_file("connections.xml");
// rest of my code here...
}
?>
if it helps, here is the error message that is being thrown.
Parse error: syntax error,
unexpected '(', expecting ',' or ';' in <path>\Connection.php on line 3
any help would be greatly appreciated, thanks. :)