Jump to content

html 5 using php documents


Recommended Posts

Hi I am trying to replace fixed names of pdf documents with variables.

This works

    <object data="Darth.pdf" type="application/pdf" width="950" height="800">
    alt : <a href="Darth.pdf">test.pdf</a>
    </object>

This fails when using a variable

    <object data=$doc type="application/pdf" width="950" height="800">
    alt : <a href=$doc>test.pdf</a>
    </object>

$doc  = "Darth.pdf"

How can I modify this HTML5 to work?
Link to post
Share on other sites

The code you provided is HTML code, not PHP. HTML doesn't know how to use a variable and that variable would be set on the server anyway. Not to mention the variable (as you've presented it is defined after you want to use it). You need to have PHP code that generates that HTML. E.g.

 

 

<?php
    $doc = "Darth.pdf";
?>
 
<object data="<?php echo $doc; ?>" type="application/pdf" width="950" height="800">
alt : <a href="<?php echo $doc; ?>">test.pdf</a>
</object>

 

Or

 

<?php
    $doc = "Darth.pdf";
    echo "<object data='{$doc}' type='application/pdf' width='950' height='800'>\n";
    echo "alt : <a href='<?php echo $doc; ?>'>test.pdf</a>\n";
    echo "</object>\n";
?>
Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.