php - How to put quotes correctly in this statement -


i need return input box function put quotes correctly. 1 please me solve error.

<?php  return " <input  style='background-color:#ccc;'type='text' name='contactname' id='contactname' value='".if(isset($_post['contactname'])) echo $_post['contactname']."' class='requiredfield' />"; 

use this

<?php  return ' <input  style="background-color:#ccc;" type="text" name="contactname" id="contactname" value="'.(isset($_post['contactname'])?$_post['contactname']:'').'" class="requiredfield" />'; 

for inline if output somthing use syntax:

( condition ? 'the thing return when condition true' : 'the false returned string' ) 

Comments