-2

I know this is wrong but I am not sure how. Can someone tell me nicely what is wrong with it?

print "<a href="https://www.google.com/chrome/browser/desktop/" target='_blank' class='gemma' style='position: fixed; bottom: 0; right: 0; text-align:right; width:100%; padding:20px;'>Works best in Chrome web browser</a>";
Case
  • 1
  • 2

1 Answers1

0

The correct way for this would be to write the HTML exactly as normal, with double quotes, and just wrap the string in single quotes. You should also use echo, not print:

echo '<a href="https://www.google.com/chrome/browser/desktop/" target="_blank" class="gemma" style="position: fixed; bottom: 0; right: 0; text-align:right; width:100%; padding:20px;">Works best in Chrome web browser</a>';
junkfoodjunkie
  • 3,168
  • 1
  • 19
  • 33
  • What is the difference between echo and print? – Case Nov 09 '16 at 16:54
  • There are slight differences, among them, echo is marginally faster than print(). You'll find more info here: http://stackoverflow.com/questions/7094118/reference-comparing-phps-print-and-echo – junkfoodjunkie Nov 09 '16 at 16:56
  • so it's kinda like using if else statements or choosing to use case statements? – Case Nov 09 '16 at 16:58
  • Sort of, yes, although you'd normally use `echo` for outputting content to the browser/UI - print is rarely used, and as stated, mostly for evaluating functions / have a specific return value. – junkfoodjunkie Nov 09 '16 at 17:00
  • Print is used rampantly in this code so I will continue with it. I see no real need to change it now. – Case Nov 09 '16 at 17:11
  • By all means, but that might be an indication that the code isn't very good, and/or in desperate need of updating. Having the `target="_blank"` suggests the same, so... proceed with caution. – junkfoodjunkie Nov 09 '16 at 17:13
  • try in desperate need of updating. I am working on that. When I start the real serious part of updating print will leave and echo will come out and play. – Case Nov 09 '16 at 17:14