【问题标题】:Why would the VSC IDE Not ignore the commented out code?为什么 VSC IDE 不会忽略注释掉的代码?
【发布时间】:2021-09-17 20:53:27
【问题描述】:

为什么 VSC IDE 不会忽略注释掉的代码? 据我了解,对象的对象属性是这样访问的:

$parentobj->$daughterobj.

所以,这应该没问题。我有一个构建表格的索引页。

  @foreach($events as $event)
     <tr>
      <td>{{ $event->id }}</td>
      <td>{{ $event->eventTitle }}</td>
      <td>{{ substr($event->eventDescription, 0, 24)}}</td>
      
      {{-- the IDE trips on the next line, Undefined variable: memory. -->
      
      <td>{{ $event->$memory->id}}</td>
      <td>{{ $event->$memory->memTitle}}</td>
      <td>{{ substr($event->$memory->memBody,0,24)}}</td>```
      **{{-- if I comment them with {{--   --}} it still complains about the Undefined variable: memory**
      
      ```<td>{{ date('Y-m-d', strtotime($event->created_at)) }}</td>
          
      <td>
          <a href="show/{{$event->id}}" class="btn btn-primary">Show</a>
          <a href="event/{{$event->id}}/edit" class="btn btn-primary">Edit</a>
          <form action="/postmem/{{$event->id}}" method="post" class="d-inline">
              {{ csrf_field() }}
              @method('DELETE')
              <button class="btn btn-danger" type="submit">Delete</button>
          </form>
      </td>
  </tr>
@endforeach

谁能告诉我为什么 IDE 会读取注释掉的行?

【问题讨论】:

  • 您使用的是哪个模板系统?您的文件的文件扩展名是什么?
  • Laravel 8,刀片文件。

标签: php comments


【解决方案1】:

因为我使用了错误的注释字符。应该是&lt;!----&gt;,而不是{!----}。坏我。

【讨论】:

  • 你能用你犯错的特定地方扩展答案吗?
  • 我正在尝试用不同的方式在 html 中编写一个循环,试图让我的观点发挥作用,
猜你喜欢
  • 2016-03-08
  • 2015-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-17
  • 1970-01-01
  • 1970-01-01
  • 2014-04-06
相关资源
最近更新 更多