Bağıl IIS taşındıktan sonra artık dont iş içerir?

2 Cevap php

Tamam, ben php hakkında sancı burada bir sürü () include gördük. Bu benim için çok acı bir nedeni haline görünüyor.

Sitemin yapısı bu gibi bir şeydir:

public_html\index.php
public_html\includes\content.inc.php
public_html\language\en\language.inc.php
public_html\classes\db.inc.php

Site çalışır Apache üzerinde hiçbir sorunları şişer. Bu (grr. .. # @!%) Ancak IIS üzerinde çalışmaz.

Let me explain: What is done is that index.php is always called by the webbrowser and depending on the request, it includes content.inc.php (there are many of these content files and index.php includes the appropriate one based on logic)

// -- index.php --
include(includes/content.inc.php);

Şimdiye kadar Apache ve IIS hem de iyi çalışır.

Şimdi content.inc.php da lang.inc.php ve db.inc.php içerir.

Bu gibi görünüyor:

// -- content.inc.php --
include(language/en/language.inc.php)
include(classes/db.inc.php)

Bu satırlar Apache üzerinde iyi çalışır, ancak IIS dahil edilecek dosya dosyaları olamaz yakınıyor.

Why? Because Apache maintains the current folder "." is public_html\ where the script execution first started. IIS on the other hand changes the meaning of "." to be the file that is currently being processed. i.e after including content.inc.php, IIS interprets "." as being public_html\includes\

Şimdi ben bir çözüm, tüm bir şekilde mutlak yolları dahil değiştirmek için olduğunu biliyorum. Anladığım kadarıyla ama benim soru, bu gerçekten bir Apache / IIS sorunu olduğunu? Bu kodda mucking olmadan doğru davranmaya yapmak için bir IIS veya PHP bir ayar var mı?

BTW, php.ini vardır

include_path=".;C:\PHP\PEAR"

2 Cevap

Sizin dosyalar tamamen DIŞ public_html ağacın olmalıdır içerir.

// Your setup should resemble:

/public_html/index.php
/includes/
/include/languages
/include/classes

// If on your phsical drives, they equate to;

c:/wwwroot/public_html/index.php
c:/wwwroot/includes/
c:/wwwroot/includes/languages
c:/wwwroot/includes/classes

: Sonra PHP.INI dosyasındaki ayarı değiştirilmesi gerekir

include_pathdaki = "; C \ PHP \ ARMUT; C:. \ wwwroot \ includes"

Wwwroot daki html koymak dizin gibi bir şey tahmin ediyorum yerlerde, gerektiği gibi değiştirin.

Yeni ini ayarını almak için IIS hizmetini yeniden başlatın.

echo ini_get('include_path') ; 

aklı tutmak için ...

Şimdi PHP hep senin dosyalarını içerir için içerir wwwroot / içine bakacağız, böylece bu yaparak dillerde / gibi şeyler içerebilir;

include 'language/eng/language.inc.php' ;

Hangi istediğiniz şeydir.

Ben genellikle böyle include '/includes/language.inc.php' olarak sunucunun kök dahil etmek istiyorum. Bu şekilde, sitenizin yapısı içinde herhangi bir klasörden çalışacaktır. Ben sadece onları çağıran farklı klasör yapıları dosyaları varken daha kolay dosyaları dahil şeyler koymak için yapar, hem de bu şekilde tüm CSS ve JavaScript bağlantı.