Home > Net >  how to add variable inside php echo
how to add variable inside php echo

Time:09-27

Why is my code not working? I am new to this. Thanks

<?php
echo "<iframe src='$_GET["name"]' style='border:none;width:100%;min-height:1000px;'></iframe>";
?>

CodePudding user response:

When you're concatenating php code with a string you've to use the syntax which is the dot sign " . "

so you're code should be like this:

<?php echo "<iframe src='".$_GET['name']."' style='border:none;width:100%;min-height:1000px;'></iframe>";?>

note how I switched the quote signs to make it realizable to to php

CodePudding user response:

<?php
  echo "<iframe src='". $_GET["name"] . "' style='border:none;width:100%;min- 
  height:1000px;'></iframe>";
?>

CodePudding user response:

You can use concatenation operator and if you check valua isset it would be better usage.

if (isset($_GET['name'])){
    echo "<iframe src='".$_GET["name"]."' style='border:none;width:100%;min-height:1000px;'></iframe>";
}
  •  Tags:  
  • php
  • Related