I need some help figuring out why the following doesn't work.
I created a class which determines what content type header to send ("text/html" or "application/xhtml+xml") depending on the browser.
If the content type is "text/html" I want to then also use preg_replace to scan the buffer to ensure that all empty closing tags have a space... so instead of "<br/>", its "<br />".
This is the structure of the class, with relevant code
From a webpage I just use 1 line, "$cn = new xmlmime();"
The callback function ("fix_code") just won't work. I've verified the reg expressions and they do work. It doesn't seem like "fix_code" is actually being called. I've also tried calling ob_start like ob_start(array("this","fix_code")), but that yielded nothing.
Any ideas? Can this actually be done the way I'm trying to do it? Thanks in advance.
I created a class which determines what content type header to send ("text/html" or "application/xhtml+xml") depending on the browser.
If the content type is "text/html" I want to then also use preg_replace to scan the buffer to ensure that all empty closing tags have a space... so instead of "<br/>", its "<br />".
This is the structure of the class, with relevant code
Code:
class xmlmime {
function xmlmime() { /*constructor*/ }
function print_headers() {
if($this->mime == 'text/html') {
$this->search[] = '/(\S)\/>/';
$this->replace[] = '$1 />';
}
ob_start("fix_code");
header('Content-Type...);
...
//end
}
function fix_code() {
return preg_replace($this->search,$this->replace,$buffer);
}
}
From a webpage I just use 1 line, "$cn = new xmlmime();"
The callback function ("fix_code") just won't work. I've verified the reg expressions and they do work. It doesn't seem like "fix_code" is actually being called. I've also tried calling ob_start like ob_start(array("this","fix_code")), but that yielded nothing.
Any ideas? Can this actually be done the way I'm trying to do it? Thanks in advance.