-5

I am trying to pass as the subject line an input parameter that a user has entered. When I try this:

$mail->Subject ='.$vehicle_type';

It prints out .$vehicle_type as the subject of the email rather than the parameter it holds.

I'm a newbie here. Tried searching this but it seems that all examples just pass a text string rather than passing the input parameter. Any help would be greatly appreciated.

John Dvorak
  • 26,799
  • 13
  • 69
  • 83

4 Answers4

1

The reason this is happening is because you pass a String towards the variable.

$item->something = '$var';

will pass the string "$var".

The reason double quotes (might) work is because the PHP interpeter will try to parse variables it finds in the string.

If you don't want to add anything else

$mail->Subject = $vehicle_type;

will work.

If you want to add extra string parts to the variable you can use

$mail->Subject = "Vehicle type: " . $vehicle_type;
Tjirp
  • 2,435
  • 1
  • 25
  • 35
0

Simply :

$mail->Subject = $vehicle_type;
Alexandre Jacob
  • 2,993
  • 3
  • 26
  • 36
0

replace with this :

 $mail->Subject =$vehicle_type; or $mail->Subject ="'".$vehicle_type."'";
Suhel Meman
  • 3,702
  • 1
  • 18
  • 26
0

$mail->Subject = $vehicle_type;

luchosrock
  • 712
  • 10
  • 24