Search code examples
phpechoundefined-index

What's the difference between the two following lines of code?


I wonder why in the world the first line of code:

echo('"'.$row['$Id'].'"');

results in output: "" while the second one:

echo('"');
echo($row['Id']);
echo('"');

Results in "71" which is exactly what I wanted to see...? I am sure that there is something simple but I don't know what is that.


Solution

  • You need to remove the $ from your code:

    echo '"'.$row['Id'].'"';
    

    Or you need to $ add it:

    echo('"');
    echo($row['$Id']);
    echo('"');
    

    Depending of what you want to achieve.