このコードが機能しない理由を教えてもらえますか? 提案されたタスクを実行する最も効率的な方法のように思えますが、Key<>Value を逆にしてもエラーが発生し続ける理由がわかりません。
テキスト文字列/配列内の #tags# を外部クラスから static::variables に置き換えようとしています。
エラー:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /home/content/57/10764257/html/marketing/includes/ProcessEmail.class.php on line 5
外部クラス:
class MyClass {
public static $firstName = "Bob"; // Initally set as "= null", assigned
public static $lastName = "Smith"; // statically through a call from
} // another PHP file.
メイン PHP ファイル:
// 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);
}
}
しかし、私はそのエラーが発生し続けます...?
ありがとうございました!