问题
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