Ben hemen hemen PHP tam bir acemi değilim. Benim arka plan C / C + + ve C #. Bazı basit bir PHP kodu şark-ify nesne çalışıyorum, ama ben yanlış bir şey yapıyorum.
Sınıf kodu:
class ConnectionString
{
public $String = "";
public $HostName = "";
public $UserName = "";
public $Password = "";
public $Database = "";
function LoadFromFile($FileName)
{
$this->String = file_get_contents($Filename);
$Values = explode("|", $this->String);
$this->HostName = $Values[0];
$this->UserName = $Values[1];
$this->Password = $Values[2];
$this->Database = $Values[3];
}
}
Kodu çağırarak:
$ConnectionString = new ConnectionString();
$FileName = "db.conf";
$ConnectionString->LoadFromFile($FileName);
print('<p>Connection Info: ' . $Connection->String . '</p>');
Filename cannot be empty: Ben belirten file_get_contents($Filename)
on line ann hatası alıyorum. Ben sabit kod $ Filename yerine dosya adı, sonra ben sadece alanlar için tüm boş dizeleri olsun.
Ne basit bir kavram eksik?