Search code examples
phpechodouble-quotessingle-quotes

PHP - insert variable in echo string


I need to insert the variable $ActID in the following string :

echo' <button class="InfoBtn" onclick="location.href=\'ActivityDetails.php?ActID=1\';" >More Info</button>';

the number 1 (ActID = 1) must be replaced by the variable $ActID like this ActID = $ActID.

I know it's very simple but I am getting very confused with the single and double quotes


Solution

  • echo' <button class="InfoBtn" onclick="location.href=\'ActivityDetails.php?ActID='.$ActID.'\';" >More Info</button>';