php - PHP 产生构建 html 代码.. 有可能吗?
问题描述
不是很懂yield PHP....网上所有的例子都不是有用的例子。
例如,在我的网络应用程序中,实际上,通过我使用的函数创建结果的 GUI:
<?php
function get_results_from_database($id) {
//connect to database
//omitted
return $array_results; //it is an array
}
现在我的html页面是这样的:
<html>
<body>
<div>
<?php
$res = get_results_from_database(5); // for example it returns 1.000 rows
foreach ( $res as $index => $row ) {
echo '<p>' . $row['Name'] . '</p>';
}
echo '<p>TOTAL ROWS: ' . count($res) . '</p>';
?>
</div>
像这样的代码可以用 yield 方法转换吗?我不明白它的含义....如果产量用于异步请求,则将其用于创建图形 HTML 页面毫无意义...或者我错过了一些东西?
我在哪里可以找到收益方法的有用示例?
解决方案
推荐阅读
- jquery - 恢复调试器后浏览器刷新
- c# - 如何更改 [Prompt.Choice] 选项的颜色?C# botframework SDK3
- python - 大型制表符分隔文件中的异常读取分块
- python - 如何对使用 confluent_kafka Consumer 的代码进行单元测试?
- node.js - 即使主机已经是 0.0.0.0,Docker 容器也会返回空响应
- list - 如何在 Haskell 中创建自己的列表?
- javascript - classList.add 已停止运行我的代码。我不知道为什么。你能?
- reactjs - 在组件上调用 Map 时未渲染的项目
- json - powershell xml到json空白文件
- php - Woocommerce rest api 与 laravel 错误集成