otuatail Posted June 23, 2016 Share Posted June 23, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/301381-html-5-using-php-documents/ Share on other sites More sharing options...
requinix Posted June 23, 2016 Share Posted June 23, 2016 Is that actually what you did? If so then you outputted "data=$doc". Either output the value of $doc at those two locations, or post your real code. Quote Link to comment https://forums.phpfreaks.com/topic/301381-html-5-using-php-documents/#findComment-1533971 Share on other sites More sharing options...
Psycho Posted June 23, 2016 Share Posted June 23, 2016 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"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/301381-html-5-using-php-documents/#findComment-1533974 Share on other sites More sharing options...
otuatail Posted June 24, 2016 Author Share Posted June 24, 2016 Ok this is partly html and I put it here because it was HTML5 and I thought that a HTML5 wiz kid could tell me better. I'll try the echo sugested by Psycho Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/301381-html-5-using-php-documents/#findComment-1533992 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.