Dosyaya dahil Sorunu

4 Cevap
<?php

//this is intializer.php
defined('DS')?  null :define('DS',DIRECTORY_SEPARATOR);

defined('SITE_ROOT')? null :
        define('SITE_ROOT',DS.'C:',DS.'wamp',DS.'www',DS.'photo_gallery');

defined('LIB_PATH')?null:define('LIB_PATH',SITE_ROOT.DS.'includes');

require_once(LIB_PATH.DS.'datainfo.php');
require_once(LIB_PATH.DS.'function.php');
require_once(LIB_PATH.DS.'session.php');
require_once(LIB_PATH.DS.'database.php');
require_once(LIB_PATH.DS.'user.php');


//this is other file where i call php file

// ERROR Use of undefined constant LIB_PATH - assumed 'LIB_PATH' in     
//C:\wamp\www\photo_gallery\includes\database.php  on 

//Notice: Use of undefined constant DS - assumed 'DS' in   
//C:\wamp\www\photo_gallery\includes\database.php on 

include(LIB_PATH.DS."database.php")

?>

Herhangi yukarıdaki hataya neden olabilecek ne gibi fikirler? Herhangi bir yardım için şimdiden teşekkür ederiz.

4 Cevap

Bu doğrudan soru ile ilgili değil,

define('SITE_ROOT',DS.'C:',DS.'wamp',DS.'www',DS.'photo_gallery');

Muhtemelen olmalıdır

define('SITE_ROOT',DS.'C:'.DS.'wamp'.DS.'www'.DS.'photo_gallery');

Bunu yapmanız gerekir:

defined('SITE_ROOT')? null : define('SITE_ROOT','C:'.DS.'wamp'.DS.'www',DS.'photo_gallery');

Eğer sitenizin kök başlamadan önce bir DIRECTORY_SEPARATOR gerekmez.

Bu ile daha iyi olabilir:

defined('SITE_ROOT')? null : define('SITE_ROOT', dirname(__FILE__));

Sürece intializer.php kök dizininde olduğu gibi

Sen database.php bu satırı eklemek zorunda

require_once("../../includes/initialise.php");

ve kaldırmak

require_once (LIB_PATH.DS."config.php");

çünkü sürekli LIB_PATH ve DS Eğer aşağıdaki kodu ekleyin erişilebilir unles değil

require_once (LIB_PATH.DS."config.php"); 

Tamam, bu yüzden ne arıyorsun gerçek system file path olduğunu düşünüyorum. Echo olabilir almak için

dirname( __FILE__ ); 

İstediğiniz herhangi bir dosya yapabilirsiniz ve bu dosyaya sistem dosyası yolu göreli olarak gösterecektir. Benim için böyle bir şey var:

/home2/myusername/public_html/project_name/includes/config.php

Eğer "proje_adı" klasöründe ilgilenen yüzden eğer böyle bir şey olmalı:

defined("SITE_ROOT") ? null : define("SITE_ROOT", DS . "home2" . DS . "myusername" . DS . "public_html" . DS . "project_name" );

Sonra arıyorsanız böyle bir şey olmalı klasörü kütüphane olacak "içeren":

defined("LIB_PATH")  ? null : define("LIB_PATH", SITE_ROOT . DS . "includes" );

Umarım bu yardımcı olur. Ben aynı sorun vardı ve bu benim için çalıştı.

Cheers, Mihai Popa