function smtp_sockopen_mx($address)
        {
                $domain = ereg_replace("^.+@([^@]+)$", "\\1", $address);
                if (!@getmxrr($domain, $MXHOSTS)) {
                        $this->log_write("Error: Cannot resolve MX \"".$domain."\"\n");
                        return FALSE;
                }
                foreach ($MXHOSTS as $host) {
                        $this->log_write("Trying to ".$host.":".$this->smtp_port."\n");
                        $this->sock = @fsockopen($host, $this->smtp_port, $errno, $errstr, $this->time_out);
                        if (!($this->sock && $this->smtp_ok())) {
                                $this->log_write("Warning: Cannot connect to mx host ".$host."\n");
                                $this->log_write("Error: ".$errstr." (".$errno.")\n");
                                continue;
                        }
                        $this->log_write("Connected to mx host ".$host."\n");
                        return TRUE;
                }
                $this->log_write("Error: Cannot connect to any mx hosts (".implode(", ", $MXHOSTS).")\n");
                return FALSE;
        }        function smtp_message($header, $body)
        {
                fputs($this->sock, $header."\r\n".$body);
                $this->smtp_debug("> ".str_replace("\r\n", "\n"."> ", $header."\n> ".$body."\n> "));                return TRUE;
        }        function smtp_eom()
        {
                fputs($this->sock, "\r\n.\r\n");
                $this->smtp_debug(". [EOM]\n");                return $this->smtp_ok();
        }        function smtp_ok()
        {
                $response = str_replace("\r\n", "", fgets($this->sock, 512));
                $this->smtp_debug($response."\n");                if (!ereg("^[23]", $response)) {
                        fputs($this->sock, "QUIT\r\n");
                        fgets($this->sock, 512);
                        $this->log_write("Error: Remote host returned \"".$response."\"\n");
                        return FALSE;
                }
                return TRUE;
        }        function smtp_putcmd($cmd, $arg = "")
        {
                if ($arg != "") {
                        if($cmd=="") $cmd = $arg;
                        else $cmd = $cmd." ".$arg;
                }                fputs($this->sock, $cmd."\r\n");
                $this->smtp_debug("> ".$cmd."\n");                return $this->smtp_ok();
        }        function smtp_error($string)
        {
                $this->log_write("Error: Error occurred while ".$string.".\n");
                return FALSE;
        }        function log_write($message)
        {
                $this->smtp_debug($message);                if ($this->log_file == "") {
                        return TRUE;
                }                $message = date("M d H:i:s ").get_current_user()."[".getmypid()."]: ".$message;
                if (!@file_exists($this->log_file) || !($fp = @fopen($this->log_file, "a"))) {
                        $this->smtp_debug("Warning: Cannot open log file \"".$this->log_file."\"\n");
                        return FALSE;;
                }
                flock($fp, LOCK_EX);
                fputs($fp, $message);
                fclose($fp);                return TRUE;
        }        function strip_comment($address)
        {
                $comment = "\\([^()]*\\)";
                while (ereg($comment, $address)) {
                        $address = ereg_replace($comment, "", $address);
                }                return $address;
        }        function get_address($address)
        {
                $address = ereg_replace("([ \t\r\n])+", "", $address);
                $address = ereg_replace("^.*<(.+)>.*$", "\\1", $address);                return $address;
        }        function smtp_debug($message)
        {
                if ($this->debug) {
                        echo $message;
                }
        }
}
?>

解决方案 »

  1.   

    $tmp->parse("data1","sample_style",true);   
    $tmp->parse("data1","sample_value",true);  改成一句:$tmp->parse("data1","sample",true);  
      

  2.   

    <select name="select" class="box" id="sample_style">
                    <!-- BEGIN sample -->   <!--这里的空格只能是一个-->
                    <option value="{sample_value}"> {sample_style}</option>
                    <!-- END sample -->    <!--这里的空格只能是一个--> </select>$tmp->set_file("hd","NewSampleRegister.htm");
    $tmp->set_block("hd","sample","data1");
    for($i=0;$i<10;$i++){$tmp->set_var("sample_style",$i);
    $tmp->set_var("sample_value",$i);
    $tmp->parse("data1","sample",true);  
    }
    $tmp->parse("out","hd");
    $tmp->p("out");
      

  3.   

    template.inc中:
      /* public: set_block(string $parent, string $handle, string $name = "")
       * extract the template $handle from $parent, 
       * place variable {$name} instead.
       */
      function set_block($parent, $handle, $name = "") {
        if (!$this->loadfile($parent)) {
          $this->halt("subst: unable to load $parent.");
          return false;
        }
        if ($name == "")
          $name = $handle;    $str = $this->get_var($parent);
        $reg = "/<!--\s+BEGIN $handle\s+-->(.*)\n\s*<!--\s+END $handle\s+-->/sm";
        preg_match_all($reg, $str, $m);
        $str = preg_replace($reg, "{" . "$name}", $str);
        $this->set_var($handle, $m[1][0]);
        $this->set_var($parent, $str);
      }
    看这句:$reg = "/<!--\s+BEGIN $handle\s+-->(.*)\n\s*<!--\s+END $handle\s+-->/sm";  \s+至少一个空格