Php 带substr的If语句Laravel

Php 带substr的If语句Laravel,php,laravel,Php,Laravel,我试图通过排序来实现,如果它是一个地球仪或智能数字,但它不起作用。先谢谢你。无论如何,这是我的代码。如果你有任何问题,请问我,否则我会解释更多 @if (substr($contact->mobile, 0, 5) == "63929" || "63959") <span class="btn btn-success">Smart</span> @elseif(substr($contact->mo

我试图通过排序来实现,如果它是一个地球仪或智能数字,但它不起作用。先谢谢你。无论如何,这是我的代码。如果你有任何问题,请问我,否则我会解释更多

@if (substr($contact->mobile, 0, 5) == "63929" || "63959")
 <span class="btn btn-success">Smart</span>
@elseif(substr($contact->mobile, 0, 5) == "63905" || "63906" || "63997")
  <span class="btn btn-primary">Globe</span>
@endif
@if(substr($contact->mobile,0,5)=“63929”| |“63959”)
聪明的
@elseif(substr($contact->mobile,0,5)=“63905”| |“63906”| |“63997”)
地球
@恩迪夫

如果您的if语句错误,您必须对每个Or测试重复整个条件:

@if (substr($contact->mobile, 0, 5) == "63929" || substr($contact->mobile, 0, 5) == "63959")
    <span class="btn btn-success">Smart</span>
@elseif(substr($contact->mobile, 0, 5) == "63905" || substr($contact->mobile, 0, 5) == "63906" || substr($contact->mobile, 0, 5) == "63997")
    <span class="btn btn-primary">Globe</span>
@endif

如果您的if语句错误,您必须对每个Or测试重复整个条件:

@if (substr($contact->mobile, 0, 5) == "63929" || substr($contact->mobile, 0, 5) == "63959")
    <span class="btn btn-success">Smart</span>
@elseif(substr($contact->mobile, 0, 5) == "63905" || substr($contact->mobile, 0, 5) == "63906" || substr($contact->mobile, 0, 5) == "63997")
    <span class="btn btn-primary">Globe</span>
@endif

你的情况不起作用

由于
| |
,PHP在这里看到了两种情况。最后一部分总是正确的

substr($contact->mobile, 0, 5) == "63929" || "63959"
您应该在数组中使用

@if (in_array(substr($contact->mobile, 0, 5), ["63929", "63959"])
  <span>
@endif
@if(在数组中(substr($contact->mobile,0,5),[“63929”,“63959]”)
@恩迪夫

您的情况不起作用

由于
| |
,PHP在这里看到了两个条件。最后一部分总是正确的

substr($contact->mobile, 0, 5) == "63929" || "63959"
您应该在数组中使用

@if (in_array(substr($contact->mobile, 0, 5), ["63929", "63959"])
  <span>
@endif
@if(在数组中(substr($contact->mobile,0,5),[“63929”,“63959]”)
@恩迪夫

我将标记为最佳答案,只需等待9分钟。知道如何制作多少个地球仪或智能?如计数?再次感谢你知道如何分别计算所有地球仪和智能。有错误语法错误,意外“:”,期待“(“抱歉,刀片模板代码中缺少一个括号。我将标记为最佳答案,只需等待9分钟。知道如何制作多少个globe或smart吗?在计数中?再次感谢您知道如何分别计算所有globe和smart。有错误语法错误,意外“:”,期待”('抱歉,刀片模板代码中缺少一个括号。请注意。不要在模板中放置这样的代码。例如,您可以像这样在
联系人
模型中添加方法:请注意。不要在模板中放置这样的代码。例如,您可以像这样在
联系人
模型中添加方法: