2011-11-29 9 views
5

に新しい行を追加する必要がI PHPで、次のクラスコードを持っている:は一度応答

<?php 

require_once CUSTOM_PATH . DIRECTORY_SEPARATOR . 'myneighborlists.php'; 

class Action_Get_route extends Frapi_Action implements Frapi_Action_Interface 
{ 

    /** 
    * Required parameters 
    * 
    * @var An array of required parameters. 
    */ 
    protected $requiredParams = array(); 

    /** 
    * The data container to use in toArray() 
    * 
    * @var A container of data to fill and return in toArray() 
    */ 
    private $data = array(); 

    /** 
    * To Array 
    * 
    * This method returns the value found in the database 
    * into an associative array. 
    * 
    * @return array 
    */ 
    public function toArray() 
    { 
     //$this->data['origin'] = $this->getParam('origin', self::TYPE_OUTPUT); 
     //$this->data['destination'] = $this->getParam('destination', self::TYPE_OUTPUT); 
     return $this->data; 
    } 

    /** 
    * Default Call Method 
    * 
    * This method is called when no specific request handler has been found 
    * 
    * @return array 
    */ 
    public function executeAction() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 

    /** 
    * Get Request Handler 
    * 
    * This method is called when a request is a GET 
    * 
    * @return array 
    */ 
    public function executeGet() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 

    /** 
    * Post Request Handler 
    * 
    * This method is called when a request is a POST 
    * 
    * @return array 
    */ 
    public function executePost() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 

    /** 
    * Put Request Handler 
    * 
    * This method is called when a request is a PUT 
    * 
    * @return array 
    */ 
    public function executePut() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 

    /** 
    * Delete Request Handler 
    * 
    * This method is called when a request is a DELETE 
    * 
    * @return array 
    */ 
    public function executeDelete() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 

    /** 
    * Head Request Handler 
    * 
    * This method is called when a request is a HEAD 
    * 
    * @return array 
    */ 
    public function executeHead() 
    { 
     $valid = $this->hasRequiredParameters($this->requiredParams); 
     if ($valid instanceof Frapi_Error) { 
      return $valid; 
     } 

     return $this->toArray(); 
    } 


} 

これは、基本的にはREST APIのクラステンプレートであると私はgetメソッドを呼び出すときに私が得た応答は常に持っていますそれに余分な新しい行。 require_onceを削除すると、余分な新しい行がなくなります。この余分な新しい行を避けるにはどうすればいいですか? This is私は新しい行を意味しました。

+0

myneighborlists.phpを調べてください。おそらく '<?php'の前または'?> 'の後に余分な改行がある可能性があります。 –

答えて

11

閉じるファイルの末尾に余分な行または空白があるかどうかを確認してください。?>必要なファイルには、スペース/行をエコーし​​ているか、ファイルの最後に余分なスペースがあります。

+3

PHPの終了タグ'?> 'はファイルの最後には常にオプションです。あなたはこの問題の可能性を半分にすることができます。 – Boann

+2

100%が同意します。投票する。 –

+0

私はそれがあなたのファイルの最後にある空白文字だと確信しています! – powtac

0

myneighborlists.phpのソースコードを見ずにこの質問に答えることは難しいです。私の推測は、このファイルの先頭に空白の行があることです。<?php