0

This should be incredibly simple but i can't seem to figure it out.

I have the following code

<?php
$bookingid='12345';
    include_once('phpToPDF.php') ;
    //Code to generate PDF file from specified URL
    phptopdf_url('https://google.com/','pdf/', $bookingid.pdf);
    echo "<a href='pdf/$bookingid.pdf'>Download PDF</a>";
?>

It echo's correctly however when it comes to generate the pdf...

phptopdf_url('https://google.com/','pdf/', $bookingid.pdf);

...it misses out the fullstop so it generates 12345pdf whereas it should be 12345.pdf.

Again, i apologise for the probable simplicity of this but i can't seem to figure it out.

2
  • $bookingid . '.pdf' Commented Jul 14, 2013 at 11:04
  • Damn - u_mulder, you beat me :) $bookingid.".pdf" Commented Jul 14, 2013 at 11:04

2 Answers 2

1
$bookingid.pdf

It tells php to concatenate variable $bookingid with constant pdf. Since constant pdf is undefined, it is casted to string and concatenated. Proper code will look like:

$bookingid . '.pdf'

or

"$bookingid.pdf"
Sign up to request clarification or add additional context in comments.

Comments

0

This should be

$bookingid.".pdf"

PHP is seeing a string concatenation, concatenating pdf' to $booking. pdf is an undefined string, so PHP helpfully assumes that you mean the text itself, but it misses the full stop you also need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.