MPDF - Including PHP Variables in html output [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Multi-line strings in PHP
8 answers
how can i replace php variable into html content by using mpdf? for example below code, i want to display variable purchasetype
in html content.
<?php
$PurchaseType = "Cash";
$html = '
<html>
<body>
<label> variable here : "phpvariable" </label>
</body>
</html>
';
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$mpdf = new MpdfMpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("Acme Trading Co. - Invoice");
$mpdf->SetAuthor("Acme Trading Co.");
$mpdf->SetWatermarkText("Paid");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->WriteHTML($html);
$mpdf->Output();
php html mpdf
marked as duplicate by Community♦ Nov 19 at 6:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
Multi-line strings in PHP
8 answers
how can i replace php variable into html content by using mpdf? for example below code, i want to display variable purchasetype
in html content.
<?php
$PurchaseType = "Cash";
$html = '
<html>
<body>
<label> variable here : "phpvariable" </label>
</body>
</html>
';
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$mpdf = new MpdfMpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("Acme Trading Co. - Invoice");
$mpdf->SetAuthor("Acme Trading Co.");
$mpdf->SetWatermarkText("Paid");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->WriteHTML($html);
$mpdf->Output();
php html mpdf
marked as duplicate by Community♦ Nov 19 at 6:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Multi-line strings in PHP
8 answers
how can i replace php variable into html content by using mpdf? for example below code, i want to display variable purchasetype
in html content.
<?php
$PurchaseType = "Cash";
$html = '
<html>
<body>
<label> variable here : "phpvariable" </label>
</body>
</html>
';
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$mpdf = new MpdfMpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("Acme Trading Co. - Invoice");
$mpdf->SetAuthor("Acme Trading Co.");
$mpdf->SetWatermarkText("Paid");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->WriteHTML($html);
$mpdf->Output();
php html mpdf
This question already has an answer here:
Multi-line strings in PHP
8 answers
how can i replace php variable into html content by using mpdf? for example below code, i want to display variable purchasetype
in html content.
<?php
$PurchaseType = "Cash";
$html = '
<html>
<body>
<label> variable here : "phpvariable" </label>
</body>
</html>
';
$path = (getenv('MPDF_ROOT')) ? getenv('MPDF_ROOT') : __DIR__;
require_once $path . '/vendor/autoload.php';
$mpdf = new MpdfMpdf([
'margin_left' => 20,
'margin_right' => 15,
'margin_top' => 48,
'margin_bottom' => 25,
'margin_header' => 10,
'margin_footer' => 10
]);
$mpdf->SetProtection(array('print'));
$mpdf->SetTitle("Acme Trading Co. - Invoice");
$mpdf->SetAuthor("Acme Trading Co.");
$mpdf->SetWatermarkText("Paid");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->WriteHTML($html);
$mpdf->Output();
This question already has an answer here:
Multi-line strings in PHP
8 answers
php html mpdf
php html mpdf
asked Nov 19 at 6:21
sigmax bpo
54
54
marked as duplicate by Community♦ Nov 19 at 6:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Community♦ Nov 19 at 6:55
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43
add a comment |
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
<label> variable here : '.phpvariable.' </label>
break string and add it to the text.
If you use "
, you can use PHP variables directly like this
$html="textual data $varibale_php and rest of the text.";
but as you have used '
, you can break the string and concatenate a value.
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
$html = '<html>'.
'<body>'.
'<label> variable here : '. $phpvariable .' </label>'.
'</body>'.
'</html>';
try like this
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
<label> variable here : '.phpvariable.' </label>
break string and add it to the text.
If you use "
, you can use PHP variables directly like this
$html="textual data $varibale_php and rest of the text.";
but as you have used '
, you can break the string and concatenate a value.
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
accepted
<label> variable here : '.phpvariable.' </label>
break string and add it to the text.
If you use "
, you can use PHP variables directly like this
$html="textual data $varibale_php and rest of the text.";
but as you have used '
, you can break the string and concatenate a value.
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
<label> variable here : '.phpvariable.' </label>
break string and add it to the text.
If you use "
, you can use PHP variables directly like this
$html="textual data $varibale_php and rest of the text.";
but as you have used '
, you can break the string and concatenate a value.
<label> variable here : '.phpvariable.' </label>
break string and add it to the text.
If you use "
, you can use PHP variables directly like this
$html="textual data $varibale_php and rest of the text.";
but as you have used '
, you can break the string and concatenate a value.
answered Nov 19 at 6:30
Danyal Sandeelo
8,11722141
8,11722141
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
add a comment |
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
1
1
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
Thank you @Danyal Sandeelo for your explanation and answer!!
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
$html = '<html>'.
'<body>'.
'<label> variable here : '. $phpvariable .' </label>'.
'</body>'.
'</html>';
try like this
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
$html = '<html>'.
'<body>'.
'<label> variable here : '. $phpvariable .' </label>'.
'</body>'.
'</html>';
try like this
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
add a comment |
up vote
0
down vote
up vote
0
down vote
$html = '<html>'.
'<body>'.
'<label> variable here : '. $phpvariable .' </label>'.
'</body>'.
'</html>';
try like this
$html = '<html>'.
'<body>'.
'<label> variable here : '. $phpvariable .' </label>'.
'</body>'.
'</html>';
try like this
answered Nov 19 at 6:33
Vinod Selvin
16919
16919
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
add a comment |
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
Thank you @Vinod Selvin!! It's working too
– sigmax bpo
Nov 19 at 6:56
add a comment |
String interpolation should help: stackoverflow.com/questions/4676417/…
– muradm
Nov 19 at 6:39
This question already answered here: stackoverflow.com/a/36525712/6730400
– Vinod Selvin
Nov 19 at 6:43