-2

Consider the following code:

<?php
$username = $_POST['username'];
echo 'How can I display a variable  inside some html code using the echo in php?';
?>
6
  • <html><?= $username; ?></html> Commented Oct 19, 2015 at 12:08
  • Your code will already do what you want. Just insert the variable inside the string, using double quotes instead of single: echo "How can I display a variable inside some html code using the echo in php? Like this: $username"; Commented Oct 19, 2015 at 12:11
  • why you give your negative opinion ? if you smart then avoid answer but every one have chance to learn. Commented Oct 19, 2015 at 12:11
  • please respect beginner. in your life you already facing this issue. Commented Oct 19, 2015 at 12:12
  • @HussyBorad who you're ranting with?! Commented Oct 19, 2015 at 12:13

2 Answers 2

0
    <?php
$username = $_POST['username'];
echo 'How can I display a variable '.$username.' inside some html code using the echo in php?';
?>
<i><?php echo $username; ?></i>
Sign up to request clarification or add additional context in comments.

Comments

0

You can write php code inside html by using php tags like

<p class='test'><?php echo "test php" ?></p>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.