描述如下:如题错误 搜了一下 可能是 语法错误 多了{}<??>  等等但是看了没有类似错误另外 删除 这段:function __destruct(){
` mysql_close($this->conId);
}后 错误就没有了是否 有什么秘密?请指教代码跟帖附上

解决方案 »

  1.   

    <?php
    class connection{
        public $conId = null;
    private $properties = array();

    function __construct(){
    $this->readConfig();

    $db_host = $this->properties["db_host"];
    $db_user = $this->properties["db_user"];
    $db_password = $this->properties["db_password"];
    $this->doConnection($db_host, $db_user, $db_password);
    }

    function __destruct(){
    ` mysql_close($this->conId);
    }


    function doConnection($db_host, $db_user, $db_password){
    $this->conId = mysql_connect($db_host, $db_user, $db_password) or die('Cannot connect to db: ' . mysql_error());
    mysql_select_db($db_name,$this->conId);
    if($this->conId){
    echo "连接成功";
    }else{
    echo "连接失败";
    }
    }

    function readConfig(){
    $file_handle = fopen("../web.config", "r");
    while (!feof($file_handle)) {
    $line = fgets($file_handle);

    $tempArray = explode("=", $line);
    for($i = 0;$i < count($tempArray);$i++){
    $temp = $tempArray[$i];
    $tempArray[$i] = trim($temp);
    }
    $property = $tempArray[0];
    $value = $tempArray[1];
    $tempArray = array($property=>$value);
    $this->properties = array_merge($this->properties , $tempArray);
    }
    fclose($file_handle);
    }
    }
    new connection();
    ?>
      

  2.   

    ` mysql_close($this->conId);
    你没发现最开头有`这个字符吗?
    `````````````````
    ``````````````````
    ```````````````````
    ```````````````````