str_replace('</head>', $this->links. '</head>', $buffer);
str_replace('</head>', '<script type="text/javascript" src="/js/jquery.js"></script></head>', $buffer);
class GeneralClass
{
private $links;
function __construct() {
ob_start(array('self', 'pageAssembly'));
}
public function includeComponent($name, $template)
{
if ($template === "") $template = "default";
$defPath = "/core/components/";
$this->links .= '<link rel="stylesheet" href="' . $defPath . $name . '/templates/' . $template . '/style.css">';
$this->links .= '<script type="text/javascript" src="' . $defPath . $name . '/templates/' . $template . '/script.js"></script>';
include_once $defPath . $name . "/templates/" . $template . "/template.php";
}
private function pageAssembly($buffer) {
return str_replace('</head>', $this->links. '</head>', $buffer);
}
}
class GeneralClass
{
static private $links;
function __construct() {
ob_start(array("self", "pageAssembly"));
}
public function includeComponent($name, $template)
{
if ($template === "") $template = "default";
$defPath = "/core/components/";
self::$links .= '<link rel="stylesheet" href="' . $defPath . $name . '/templates/' . $template . '/style.css">';
self::$links .= '<script type="text/javascript" src="' . $defPath . $name . '/templates/' . $template . '/script.js"></script>';
include_once $defPath . $name . "/templates/" . $template . "/template.php";
}
public function pageAssembly($buffer) {
return str_replace('</head>', self::$links . '</head>', $buffer);
}
}
Find more questions by tags PHP
Actually, no. Just you have to code it as a static context. It hurt to do normal?
ob_start([$this, 'pageAssembly']);
And if someone (we will not point fingers) have included the error output immediately about it would know. But someone (again, we omit the time with a finger) cut off their nafig, in this and enjoys challenges) - Chelsie.Man commented on April 19th 20 at 12:18