2012-10-13 24 views
2

我在這個美好的夜晚使用了laravel,當時我st upon這個坦率地說我從未見過的奇怪錯誤。我簡單地遍歷一些數組並嘗試在視圖文件中打印出一些值。調用未定義的函數Â()

錯誤:

Unhandled Exception 

Message: 

Error rendering view: [controller.index] 

Call to undefined function Â() 
Location: 

/web/storage/views/7b064aafcdba902ea2c593167b6df491 on line 4 

代碼:

@section('content') 
    <?php $i = 0; $current = 0 ?> 
    @foreach($data as $date => $episodes) 
     @if($i == 0 || ($i % 5 == 7 && $i == $current + 1)) 
      <tr> 
      <?php $current = $i; ?> 
     @endif 

     @foreach($data as $day) 
      <td> 
       @foreach($day as $episode) 
        {{ $episode->title }} 
       @endforeach 
      </td> 
     @endforeach 


     @if($i % 5 == 7 && $i == $current + 7) 
      <tr> 
      <?php $current = $i; ?> 
     @endif 
     <?php $i++; ?> 
    @endforeach 
@endsection 

而且編譯版本:

<?php \Laravel\Section::start('content'); ?> 
    <?php $i = 0; $current = 0 ?> 
    <?php foreach($data as $date => $episodes): ?> 
     <?php if($i == 0 || ($i % 5 == 7 && $i == $current + 1)): ?> 
      <tr> 
      <?php $current = $i; ?> 
     <?php endif; ?> 

     <?php foreach($data as $day): ?> 
      <td> 
       <?php foreach($day as $episode): ?> 
        <?php echo $episode->title ; ?> 
       <?php endforeach; ?> 
      </td> 
     <?php endforeach; ?> 


     <?php if($i % 5 == 7 && $i == $current + 7): ?> 
      <tr> 
      <?php $current = $i; ?> 
     <?php endif; ?> 
     <?php $i++; ?> 
    <?php endforeach; ?> 
<?php \Laravel\Section::stop(); ?> 

這可能是一個簡單的解決方案,但我不能找到什麼好Google上的結果。幫我理解這個錯誤! :)

+3

這看起來像一個模板...你不能繼續用這種方法來壓制PHP錯誤 – Baba

+0

如果你能恢復它(並且它包含轉換後的php代碼,那麼你應該向我們展示模板文件'7b064aafcdba902ea2c593167b6df491') 。否則,請爲Laravel提供錯誤報告,因爲此錯誤消息有點用處。 – mario

+0

看起來像一個編碼錯誤,但編譯後的模板會告訴更多... – Sven

回答

4

您刪除的空間是而不是空間。它實際上是一個非破壞性空間(U + 00A0)。贈品是「Â」,它表現爲U + 0080和U + 00BF之間的字符的第一個字節,當編碼爲UTF-8但誤解爲Latin-1時。出於某種原因,PHP編譯器不認爲它是空白的,因此試圖將其用作普通標識符。

+1

是的謝謝澄清。我必須在我的macbook上滑動alt +空格。最奇怪的是,它沒有在Sublime Text 2或Smultron中顯示隱藏字符時出現,只有Coda能夠識別問題。 – Ms01

+1

@cubsink,男士,謝謝!這一直在推動我瘋狂的月!我不知道我甚至在一半時間內都輸入了ALT-SPACE,幾乎在每個程序中都沒有出現任何不同。蘋果應該真的強烈警告每個開發者關於ALT-SPACE,呃「功能」。我喜歡我的Mac,但有時我真的很討厭他們做事的方式。我希望我能對+1000發表評論。 – Donamite

+0

歡迎您,但伊格納西奧爲我解決了這個問題:P – Ms01

0

這顯然是一個編碼問題,它是如何成爲一個大問題壽(因爲我只在UTF-8工作)。

Encoding problem

刪除了OR語句(||)後面的空格(^),現在它完美的作品。