PHP kodu ve linefeeds / Satır Başları

2 Cevap

Mysql_connect çağrılırken aşağıdaki kod düzenleme, yani herhangi bir sorun neden olur Sadece merak:

public function connect() {
    mysql_connect($this->host,
                  $this->username,
                  $this->password)
        or die("Could not connect. " . mysql_error());

ya da tek bir satırda bütün olması gerekiyor, yani:

mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());

Teşekkürler.

2 Cevap

Belirteçleri arasındaki boşluk (bu durumda satırsonu içerir) ilgisizdir. Hatta isterseniz bu gibi görünmesi olabilir

public
function
connect
(
)
{
mysql_connect
(
$this
->
host
,
$this
->
username
,
$this
->
password
)
or
die
(
"could not connect. "
.
mysql_error
(
)
)
;
}

hayır, boşlukları hemen hemen her dilde olduğu gibi php göz ardı edilir (python özel bir durum olan, ama yine de Python satırları ayırabilirsiniz)