2009-06-24 60 views
0

我正在调用一个看起来没有执行任何方法的类。考虑以下文件(DB-com.php):控件没有进入PHP类文件

echo "entered db-com.php"; 
class DBCom { 
    /** 
    * @var string Holds the query string. 
    * If the blank constructor is used, make sure to use the parametrized functions. 
    */ 
    var $queryString; 

    /** 
    * @var resource Holds the MySQL Resource returned by mysql_query function 
    */ 
    var $queryResult; 

    /** 
    * @var array Holds the entire array of the result. 
    */ 
    var $queryArray; 

    function __construct() { 
     $this->queryString = $this->queryResult = $this->queryArray = ''; 
    } 
    function __construct($qS) { 
     $this->queryString = $qS; 
     $this->queryResult = mysql_query($this->queryString); 
     $this->queryArray = ''; 
    } 

    /** 
    * 
    * @return array An array containing all the elements of the requested query. 
    */ 
    function get_query_array() { 
     if($this->queryString == '' || $this->queryString == "") { 
      die("Query String is Empty. Cannot Proceed."); 
     } 
     for ($i = 0 ; $fetchedArray = mysql_fetch_array($this->queryResult) ; $i++) { 
      $this->queryArray[$i] = $fetchedArray; 
     } 
     return $this->queryArray; 
    } 
} 

当在另一个文件中写到:

require ('some_path/db-com.php'); 

它甚至没有进入这个文件。即使第一个echo声明不显示。

这不会发生在任何其他类文件中。只有这种涉及SQL函数的类。所以我甚至开始了一个干净的空白文件,首先测试控制是否进入它(它做了),然后写下所有这些,用不同的名字保存并包含它,并再次出现这个神秘的错误。

我哪里出错了?

+0

有什么错误? – 2009-06-24 16:27:17

+1

你不需要制作这个社区wiki。 – Kev 2009-06-24 16:27:24

+0

@zack多数民众赞成在问题,什么都没有来,控制不进入文件:) @kev我只是让他们每个人都是一个wiki,除非另有要求。有时帮助。 :) – OrangeRind 2009-06-24 16:42:51

回答

3

你有两个__construct()方法。你不能在PHP中重载类似的方法。

你可能已经display_error小号关闭,所以这就是为什么你不能看到错误消息:

Fatal error: Cannot redeclare DBCom::__construct() in C:\test.php on line 23

0

健全检查:你有一个是空的或以其他方式过时的路径上的其它文件?

1

你在干什么<?php ?>