【发布时间】:2013-05-01 12:42:37
【问题描述】:
谁能告诉我为什么这段代码不起作用?这似乎是完成所提议任务的最有效方法,我不明白为什么我不断收到错误 - 即使我反转 KeyValue。
我正在尝试用 static::variables 替换文本字符串/数组中的#tags#,形成一个外部类。
错误:
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);
}
}
但我一直收到这个错误...?
谢谢!
【问题讨论】:
-
把你的完整代码ProcessEmail.class.php。那么调试起来就很简单了。