0

I am a novice coder and I have a php variable that I need to put a php snippet inside, but I always get a syntax error.

The code goes something like this:

$f_data= '
Invoice By : '.$user.'
Status : '.$Status.'
Customer Name : '.$cname.'
Company : '.$company.'
PoS : '.$pos.'
';

And I am trying to put another php snippet inside the above variable which hides a particulare line if a variable is empty like this:

$f_data= '
'<?php if (isset($user) && !empty($user)) { ?>' Invoice By : '.$user.' '<?php } ?>'
Status : '.$Status.'
Customer Name : '.$cname.'
Company : '.$company.'
PoS : '.$pos.'
';

I always get the error "Parse error: syntax error, unexpected '?'" with this line.

Please help me find what 'm doing wrong here.

Thanks for your help.

Cody Coderson
  • 411
  • 1
  • 9
  • 21
  • Why are you putting your PHP inside of quotes? Do that work outside of the string and concatenate it in just like you do with the other variables. – John Conde May 14 '18 at 11:57
  • The variables inside the $f_data= quotes are retrieved via form sumit, and I want to hide the lines if the variable is empty, hence the php code is there to execute and hide the line. – Cody Coderson May 14 '18 at 12:00

0 Answers0