Can somebody tell me why this code is not working? It seems like the most efficient way to do the proposed task, I don't understand why I keep getting an error - even when I reverse the Key<>Value.
I am trying to replace #tags# within a text string/array with static::variables form an external class.
ERROR:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /home/content/57/10764257/html/marketing/includes/ProcessEmail.class.php on line 5
EXTERNAL CLASS:
class MyClass {
public static $firstName = "Bob"; // Initally set as "= null", assigned
public static $lastName = "Smith"; // statically through a call from
} // another PHP file.
MAIN PHP FILE:
// This is the array of find/replace strings
private static $tags = array("#fistName#", MyClass::$firstName,
"#lastName#", MyClass::$lastName);
// This jumps trough the above tags, and replaces each tag with
// the static variable from MyClass.class.php
public static function processTags($message) {
foreach ($tags as $tag => $replace) {
$message = str_replace($tag, $replace, $message);
}
}
But I keep getting that error...?
Thank you!