Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in C:xampphtdocsAttendanceSystemresourcesphpmethod.php on line 250

How to echo php variable in html that in String

$body = '<p style="font-size: 18px; line-height: 1.2; text-align:; word-break: break-word; mso-line-height-alt: 22px; margin: 0;"><span style="color: #2b303a; font-size: 18px;"><strong>Name: </strong><span style="font-size: 16px;">'echo $student_name'</span></span></p>'

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

You don’t need to echo it. You can just add it to the string since we’re in PHP at that point:

'<span style="font-size: 16px;">' . esc_html( $student_name ) . '</span></span></p>'

You should also escape any variables you’re adding to HTML strings using esc_html() in case the strings contain HTML tags not just plain text.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x