php - 使用 laravel 在代码中间结束一个 for 循环
问题描述
我的页面如下所示:
@foreach
//create a div here
//and the div needs to use the outside function like
<input value="{{ showText }}"> // there is a form as well
// and the foreach ends.
@endforeach
<?php
//and the function is here.
function showText(){
//connect to database
//get the required information
//return the information
}
现在,该showText()
函数返回一个 id,它用于更新数据库中的信息。但是,由于@foreach
, showText() 函数不返回任何内容,并且 Laravel 显示 id 不能为 null 或类似的错误。当我前段时间使用 PHP 做同样的事情时,我可以这样做:
<?php
for(){
?>
<div> Get the data through AJAX </div>
<?php
}
那么,我如何使用 laravel 做同样的事情呢?
解决方案
推荐阅读
- opengl - 如何羽化文字显示效果
- node.js - BCrypt错误非法参数:字符串,对象
- wpf - 选中/取消选中 wpf mvvm 中的复选框
- ggplot2 - 在ggplot中组合数据集的不同部分
- java - 如何使用上下文作为参数获取函数的返回值?
- vue.js - Vue mapState 对象正在改变 vuex 状态
- wordpress - 应用用户角色定价规则时,无法将每单位的后缀(例如:6.50 / kg)添加到用户角色定价后缀(woocommerce 使用价格插件)
- python - pd.read_excel 无法读取 xlsm 文件
- iterator - WSO2 Iterate Mediator 为 WSO2 EI 中的每个迭代迭代相同的元素
- java - jlink:ed 应用程序中的记录引发异常