【发布时间】:2022-08-04 16:53:02
【问题描述】:
在我的代码中,我使用所有静态类,例如:Parsedown::text(\'text\');,如果我尝试像这样使用它,它会给我一条错误消息“不在对象上下文中使用 $this”,但我无法弄清楚如何像这样使用 Parsedown 因为我只能像这样实例化它:
$Parsedown = new Parsedown();
echo $Parsedown->text(\'text\');
函数文本代码
function text($text)
{
# make sure no definitions are set
$this->DefinitionData = array();
# standardize line breaks
$text = str_replace(array(\"\\r\\n\", \"\\r\"), \"\\n\", $text);
# remove surrounding line breaks
$text = trim($text, \"\\n\");
# split text into lines
$lines = explode(\"\\n\", $text);
# iterate through lines to identify blocks
$markup = $this->lines($lines);
# trim line breaks
$markup = trim($markup, \"\\n\");
return $markup;
}
如何使用 parsedown static ?
-
为什么当它显然不是为此而设计的时,你想使用它静态吗?
-
由于我使用我所有的静态类,它保持我的代码顺序