kuau
05-20-2009, 03:28 AM
Can someone please tell me how this code works and if it is the best way to replace variables? It seems to me that the guy just wants to use the variable values in some email messages. Why not use $_POST variables? I know he wrote if for php4 and I thought global variables were frowned upon in php5 (?).
I also don't get the use of $body_text without the dot -- doesn't it just keep replacing the value rather than appending? What is the point of it? Don't you just end up with $body_text equal to the last value? The emails seem to work OK but I'm not sure if this code has anything to do with it. $body_text is not mentioned anywhere in the email.
function replace_email_template_variables($body_text) {
// This function will replace the variables in the Body text for the email... uses several global variables.
global $Today;
global $First_Name;
global $Last_Name;
global $Phone;
global $Email;
global $DriverLicenseFrom;
global $Age_Group;
global $Flight;
global $Cruise;
global $Credit_Card;
global $Best_Price_Net;
global $Best_Price_Full;
global $New_Pick_Date;
global $N_Pick_Time;
global $Pick_Location;
global $Pick_AP;
global $New_Drop_Date;
global $N_Drop_Time;
global $Drop_Location;
global $Drop_AP;
global $Car_Class;
global $Days_Num;
global $country;
global $agencyname;
global $employee;
$body_text = eregi_replace('%Today%', $Today, $body_text);
$body_text = eregi_replace('%First_Name%', $First_Name, $body_text);
$body_text = eregi_replace('%Last_Name%', $Last_Name, $body_text);
$body_text = eregi_replace('%Phone%', $Phone, $body_text);
$body_text = eregi_replace('%Email%', $Email, $body_text);
$body_text = eregi_replace('%DriverLicenseFrom%', $DriverLicenseFrom, $body_text);
$body_text = eregi_replace('%Age_Group%', $Age_Group, $body_text);
$body_text = eregi_replace('%Flight%', $Flight, $body_text);
$body_text = eregi_replace('%Cruise%', $Cruise, $body_text);
$body_text = eregi_replace('%Credit_Card%', $Credit_Card, $body_text);
$body_text = eregi_replace('%Best_Price_Net%', $Best_Price_Net, $body_text);
$body_text = eregi_replace('%Best_Price_Full%', $Best_Price_Full, $body_text);
$body_text = eregi_replace('%New_Pick_Date%', $New_Pick_Date, $body_text);
$body_text = eregi_replace('%N_Pick_Time%', $N_Pick_Time, $body_text);
$body_text = eregi_replace('%Pick_Location%', $Pick_Location, $body_text);
$body_text = eregi_replace('%Pick_AP%', $Pick_AP, $body_text);
$body_text = eregi_replace('%New_Drop_Date%', $New_Drop_Date, $body_text);
$body_text = eregi_replace('%N_Drop_Time%', $N_Drop_Time, $body_text);
$body_text = eregi_replace('%Drop_Location%', $Drop_Location, $body_text);
$body_text = eregi_replace('%Drop_AP%', $Drop_AP, $body_text);
$body_text = eregi_replace('%Car_Class%', $Car_Class, $body_text);
$body_text = eregi_replace('%Days_Num%', $Days_Num, $body_text);
$body_text = eregi_replace('%country%', $country, $body_text);
$body_text = eregi_replace('%Employee%', $employee, $body_text);
return ($body_text);
}
Further down there is this:
$body = replace_email_template_variables($body);
but no mention of $body except in some commented-out text. I just don't get it. Thanks for any light you can shed on this. e :)
I also don't get the use of $body_text without the dot -- doesn't it just keep replacing the value rather than appending? What is the point of it? Don't you just end up with $body_text equal to the last value? The emails seem to work OK but I'm not sure if this code has anything to do with it. $body_text is not mentioned anywhere in the email.
function replace_email_template_variables($body_text) {
// This function will replace the variables in the Body text for the email... uses several global variables.
global $Today;
global $First_Name;
global $Last_Name;
global $Phone;
global $Email;
global $DriverLicenseFrom;
global $Age_Group;
global $Flight;
global $Cruise;
global $Credit_Card;
global $Best_Price_Net;
global $Best_Price_Full;
global $New_Pick_Date;
global $N_Pick_Time;
global $Pick_Location;
global $Pick_AP;
global $New_Drop_Date;
global $N_Drop_Time;
global $Drop_Location;
global $Drop_AP;
global $Car_Class;
global $Days_Num;
global $country;
global $agencyname;
global $employee;
$body_text = eregi_replace('%Today%', $Today, $body_text);
$body_text = eregi_replace('%First_Name%', $First_Name, $body_text);
$body_text = eregi_replace('%Last_Name%', $Last_Name, $body_text);
$body_text = eregi_replace('%Phone%', $Phone, $body_text);
$body_text = eregi_replace('%Email%', $Email, $body_text);
$body_text = eregi_replace('%DriverLicenseFrom%', $DriverLicenseFrom, $body_text);
$body_text = eregi_replace('%Age_Group%', $Age_Group, $body_text);
$body_text = eregi_replace('%Flight%', $Flight, $body_text);
$body_text = eregi_replace('%Cruise%', $Cruise, $body_text);
$body_text = eregi_replace('%Credit_Card%', $Credit_Card, $body_text);
$body_text = eregi_replace('%Best_Price_Net%', $Best_Price_Net, $body_text);
$body_text = eregi_replace('%Best_Price_Full%', $Best_Price_Full, $body_text);
$body_text = eregi_replace('%New_Pick_Date%', $New_Pick_Date, $body_text);
$body_text = eregi_replace('%N_Pick_Time%', $N_Pick_Time, $body_text);
$body_text = eregi_replace('%Pick_Location%', $Pick_Location, $body_text);
$body_text = eregi_replace('%Pick_AP%', $Pick_AP, $body_text);
$body_text = eregi_replace('%New_Drop_Date%', $New_Drop_Date, $body_text);
$body_text = eregi_replace('%N_Drop_Time%', $N_Drop_Time, $body_text);
$body_text = eregi_replace('%Drop_Location%', $Drop_Location, $body_text);
$body_text = eregi_replace('%Drop_AP%', $Drop_AP, $body_text);
$body_text = eregi_replace('%Car_Class%', $Car_Class, $body_text);
$body_text = eregi_replace('%Days_Num%', $Days_Num, $body_text);
$body_text = eregi_replace('%country%', $country, $body_text);
$body_text = eregi_replace('%Employee%', $employee, $body_text);
return ($body_text);
}
Further down there is this:
$body = replace_email_template_variables($body);
but no mention of $body except in some commented-out text. I just don't get it. Thanks for any light you can shed on this. e :)