I have a variable $RepCom if it isset, I want it to be the value of the input RepCom.
I’m trying to figure out the right way to make this work…
$x_RepCom = '<input name="RepCom" type="text" value="'. if(isset($RepCom)){echo $RepCom; }.'">';
Just dumping the variable is fine, but I get a Undefined error if it is not set.
$x_RepCom = '<input name="RepCom" type="text" value="'.$RepCom.'">';
So how do I put the if isset for the $RepCom into the value of the input?
I tryed…
$x_RepCom = '<input name="RepCom" type="text" value="<?php if(isset($RepCom)){echo $RepCom; }?>">';
But that just dumps the string <?php if(isset($RepCom)){echo $RepCom; }?> into the value.
What am I missing?
You would probably want to put the value as an variable:
Now if it is not set, it will be given value of an empty string, which will prevent the undefined error.