运行 php mPDF 中的函数

Run php function in mPDF

你好。在 mPDF html 代码中尝试 运行 php 函数时遇到问题。例如:

funtion.php:

function write(){echo "123"}

mPDF 文件:

$html ='<html>'.write().'</html>';

但在 pdf 文件中不显示“123”

function write(){
   $message = "123";
   return $message;
}

使用 return 而不是 echo。您想要打印函数的输出,而不是函数中打印的内容。

  • 小记:在这个例子中echo也可以,错误在你的语法中。

您应该得到 syntax error, unexpected '}', expecting ',' or ';',将函数更改为:

function write(){echo "123";}