在mPDF中运行php函数 [英] Run php function in mPDF
本文介绍了在mPDF中运行php函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Helllo.尝试在mPDF html代码中运行php函数时遇到问题.例如:
Helllo. I have a problem when try run php function in mPDF html code. For examle:
funtion.php:
funtion.php:
function write(){echo "123"}
mPDF文件:
$html ='<html>'.write().'</html>';
但在pdf文件中不显示"123"
but in pdf file not display "123"
推荐答案
function write(){
$message = "123";
return $message;
}
使用return代替 echo
.您希望不打印功能中输出的内容而打印功能的输出.
Use return instead of echo
. You want to print the output of your function not something that is printed in the function.
- 小笔记:在此示例中,
echo
也可以使用,错误在于您的语法.
- small note: in this example
echo
will also work, the error is in your syntax.
您应该得到一个语法错误,意外的'}',期望为','或';'
,将函数更改为:
You should be getting a syntax error, unexpected '}', expecting ',' or ';'
, change your function to:
function write(){echo "123";}
这篇关于在mPDF中运行php函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文