任何人都可以看到我所做的使用这个类的错误,它应该改变之前的单词,但它只是坐在那里什么都不做。 第二PHP PGM是我使用的实际班组长..如何让这个php类按预期工作
<?php
include("parse.inc.php");
$bob = new parseClass();
$tag = "{Before}";
$replacement = "After";
$content = "My animal runs around all over the place and his name is {Before}.";
$bob->ReplaceTag($tag, $replacement, $content);
echo $bob;
?>
parse.inc.php (file name)
***************************
<?php
Class parseClass {
function ReplaceTag($tag, $replacement, $content) {
$content = str_replace($tag, $replacement, $content);
return $content;
}
}
// END Class parseClass
?>
如果不是字符串,你可以不回对象。在你的情况'echo $ bob;'实际上是一个对象。您需要使用var_dump或print_r – chudasamachirag
如果答案为您提供了所需的信息,请单击答案左侧的绿色复选标记以接受它。这将确保你的问题不会永远得不到解答,并且是向帮助你的人表示感谢。 –