0

I get the variable in echo $id; and the hyperlink can pass the value.

In third line's id=$id it is not displaying the value It is directly displaying $id.

$id= $_GET['id'];
echo $id;
echo '<input type="text" value="localhost/anews/singleeng.php?id=$id" id="myInput">
echo "<a href='generateeng.php?id=$id'> Link </a>";
Sakib
  • 13
  • 5

1 Answers1

0

That's because in the third line you are using a single quote.

In php single quoted strings will display things almost completely "as is." Variables and most escape sequences will not be interpreted.

This should work.

$id = $_GET['id'];
echo '<input type="text" value="localhost/anews/singleeng.php?id='.$id.'" id="myInput">';

For more details on single vs double quoted string have a look at this answer

Gigitsu
  • 593
  • 6
  • 19