Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I echo one HTML line in PHP?

Tags:

html

php

I want to echo this line in PHP simply by using "echo", but it doesn't work. How can I fix it?

echo '<p><input type="button" name="Back" value="Back" onclick="window.location ='viewusers.php'" /></p>'
like image 339
manxing Avatar asked Apr 11 '26 02:04

manxing


1 Answers

You need to escape the quotes, or better, change to single quotes like this: (still needs escaping at the end there)

echo '<p><input type="button" name="Back" value="Back" onclick="window.location =\'viewusers.php\'" /></p>';

It's better to do single quotes because then php doesn't parse it like it does with double quotes. A better explanation is in the php docs.

Another option is to close the php block, like this: (then you don't have to worry about escaping quotes)

<?php
  [your php code]
?>
[your html line or block]
<?php
  [more php]
?>
like image 135
cambraca Avatar answered Apr 12 '26 14:04

cambraca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!