Run php function in mPDF

旧街凉风 提交于 2021-02-11 13:59:16

问题


Helllo. I have a problem when try run php function in mPDF html code. For examle:

funtion.php:

function write(){echo "123"}

mPDF file:

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

but in pdf file not display "123"


回答1:


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

Use return instead of echo. You want to print the output of your function not something that is printed in the function.

  • 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";}


来源:https://stackoverflow.com/questions/59946483/run-php-function-in-mpdf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!