Ive just started learning php and im begining to get a little confused with some elements of php, the main issue being around the users visability of php code.
I have noticed that if you select the "view page source" option on a webpage in firefox the HTML code is shown but not the php, i assume that this is because either
1) The firefox source viewer does not support php
or
2) The web server (apache in this case) "compiles" the php and therefor the original code is not passed on to the webpage user
The reason that this interests me is that I have the following code which holds the username and password for my MySQL database hard coded into a php file
Code: Select all
class DataBaseConfig
{
public $Username = "root";
public $Password = "password";
private $m_Localhost = "LocalHost";
private $m_DatabaseName = "UsersDatabase";
private $m_DatabaseTableName = "UserData";
public function ConnectToDataBase()
{
$DatabaseConnection = mysql_pconnect($this->m_Localhost, $this->Username, $this->Password);
if (!$DatabaseConnection)
echo "Error connecting to database.\n";
mysql_select_db($this->m_DatabaseName) or die ("Unable to select database!");
}
I would also be interested to know if this is how database connection information is commonly stored or are other more secure methods used?
If anyone could help me to understand this it would be greatly appreciated.
Thanks,
Magnumwolf