2013-08-28 137 views
-2

我有類數據庫與錯誤致命錯誤:無法重新聲明類屬性.... Properties.php(屬性是近java.util的實現。屬性API爲PHP 5版權所有(C)2005克雷格萬利)致命錯誤:無法重新聲明類屬性....屬性.php

<?php 
    include_once("common/libs/Properties.php"); 
     // if (!class_exists('Properties')) { 
     // require_once("common/libs/Properties.php"); 
     // } 
     class Database { 
      var dbhost; 



      function __construct() { 

       $dbIpAddressProp = new Properties(); 
     //   $dbIpAddressProp->load(file_get_contents('./confEMS',FILE_USE_INCLUDE_PATH)); 
     //   $this->dbhost = $dbIpAddressProp->getProperty("dbIpAddress"); 

      } 
      function __destruct() { 
       pg_close($this->dbconn); 
     //  echo 'destruct'; 
      } 

     } 
    ?> 
+0

和Properties.php裏面有什麼? –

+0

錯誤消息應該提供更多信息,例如最初聲明屬性的位置以及要重新聲明它的位置 –

+0

它是一個API:PHP 5的java.util.Properties API的實現版權所有(C )2005年Craig Manley – user1310873

回答

0

你可能會包括在你的其他PHP文件Properties.php不止一次。 首先確保您沒有在Properties.php中聲明兩次類Properties。然後,你需要檢查你的所有包含。我強烈建議你使用xdebug或其他任何東西來檢查錯誤堆棧。然後你可以找出這個錯誤來自哪裏。

無論何時想要包含properties.php,都應該使用include_once。 (因爲它包含一個類,並且一個類不能被重新聲明)

相關問題