简体   繁体   English

.php文件中html中的php

[英]php in html in .php file

working in wordpress here. 在WordPress上工作。

I have this code to trigger a popup for a plugin. 我有这段代码来触发插件的弹出窗口。

<?php PopupContact(); ?>

It is supposed to insert a contact us button, and trigger a popup when clicked. 应该插入一个“ contact us按钮,并在单击时触发一个弹出窗口。

In another .php file, I have the following code 在另一个.php文件中,我有以下代码

<p><?php wc_ps_ict_t_e( 'No Result Text', __('Click Here To Request A Quote For A Part That Hasn\'t Made It To Our Site Yet.', 'woops') ); ?></p>

What I would like to do is replace "Click here" with the Contact Us button 我想做的是将"Click here"替换为"Click here" Contact Us按钮

However I cannot insert the <?php PopupContact(); ?> 但是我不能插入<?php PopupContact(); ?> <?php PopupContact(); ?> successfully. <?php PopupContact(); ?>成功。

when I attempt 当我尝试

<p><?php wc_ps_ict_t_e( 'No Result Text', __('<?php PopupContact(); ?> To Request A Quote For A Part That Hasn\'t Made It To Our Site Yet.', 'woops') ); ?></p>

The browser only returns "To Request A Quote For A Part That Hasn't Made It To Our Site Yet" 浏览器仅返回"To Request A Quote For A Part That Hasn't Made It To Our Site Yet"

If you could provide any information on why this is happening, and anything I could do to fix it I would really appreciate it. 如果您能提供有关为什么发生这种情况的任何信息,以及我能做的任何修复工作,我将不胜感激。

If you need any more information from me, please ask. 如果您需要我的更多信息,请询问。

Thank you. 谢谢。

Based on how I read the code, PopupContact() does an echo in and of itself. 根据我阅读代码的方式,PopupContact()本身会进行回显。 If you want to put the contents of that echo into something else, you'll need to use output buffering. 如果要将回显的内容放入其他内容,则需要使用输出缓冲。

<?php
  ob_start();
  PopupContact();
  $popup = ob_get_contents();
  ob_end_clean();
?>
<p><?php wc_ps_ict_t_e( 'No Result Text', __($popup.' To Request A Quote For A Part That Hasn\'t Made It To Our Site Yet.', 'woops') ); ?></p>

Generally, functions shouldn't echo out like this, but I'm not sure what the rest of your stack looks like. 通常,函数不应像这样回显,但我不确定其余堆栈的外观。 You should also check out the contents of $popup to make sure that it isn't too complex to go into your output function. 您还应该检查$ popup的内容,以确保输入输出函数不会太复杂。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM