php - 如何获取 PHP 标签之间的函数的 HTML 内容?
问题描述
这是一个简单的问题,但我从未见过解决它的方法。我想将我的 HTML 传递给 PHP 标签之间的函数
例子:
<?php $thisVar = ?>
<h2>Here is my desired HTML<h2>
<p>Here is my desired HTML<p>
<?php ; callFunction($thisVar);?>
我知道这是不可能的,所以我做了这样的事情:
<?php $thisVar = '
<h2>Here is my desired HTML<h2>
<p>Here is my desired HTML<p>
'; callFunction($thisVar);?>
甚至
<?php callFunction('
<h2>Here is my desired HTML<h2>
<p>Here is my desired HTML<p>
');?>
最后两个示例有效,但是当我使用长 HTML 作为变量时,它变得杂乱无章。有没有办法像第一个例子那样做?在所需的 HTML 变量之前和之后打开和关闭 PHP 标记?
谢谢!
解决方案
推荐阅读
- angular - ng serve 抛出错误“服务命令需要在 Angular 项目中运行,但找不到项目定义”
- amazon-web-services - 具有 cloudformation 的 aws CAPABILITY_AUTO_EXPAND 控制台 Web 代码管道
- ada - 如何在 Ada 中为向量实现 Generic_Sorting?
- angular - 更改角度导航的基本href
- database - 数据库性能事务与比较
- git - 尝试使用备用 hexo 主题时无法在 Netlify 上部署网站
- asp.net - 网页上的字符在刷新时发生变化
- c# - 如何将类序列化为 XML
- linux - 删除除特定目录之外的所有目录
- java - 使用 DBUnit 从控制台关闭 SLF4J