Class returing Cannot re-assign $this
Posted: Sun Jun 08, 2008 6:05 pm
I am writing one of my first classes... or at least attempting...
I am trying to achieve the same thing in the class as below:
This is what I have:
I just can't get the code to work without returing "Fatal error: Cannot re-assign $this ..."
I am trying to achieve the same thing in the class as below:
Code: Select all
function connect($dbc_name = $default){
...
}Code: Select all
<?php
class db {
private $db_host = '.com';
private $db_user = 'sandboxuser';
private $db_pass = 'sandbox';
private $db_name = 'sandbox';
private $dbc_name;
function connect($this->dbc_name = $this->db_host){
$this->connectionLink = mysql_connect($this->db_host, $this->db_user, $this->db_pass);
if($this->connectionLink){
mysql_select_db($this->db_name, $this->connectionLink);
}
}
}
$test = new db();
$test->connect();
?>