Ad

PHP String With Variable

- 1 answer

how do i add a string with a variable within the subject of a notification email? i am wanting to add data from the api into the subject email but unsure on how i pass that in with a string message inbetween to form a sentence.

i want this message

`$subject = 'Hi:' $filmName 'is part of your suggestions'`

or

$subject = 'Hi:' $fullName, 'the film' $filmName, 'has been recommended'

then i can do this with the subject in the toMail method

 return (new MailMessage())
        ->subject($subject)
Ad

Answer

Try this -

$subject = 'Hi: '.$fullName.', the film '.$filmName.', has been recommended';
Ad
source: stackoverflow.com
Ad