Witam!
Używam w mojej klasie funkcji bb2html() podanej kiedyś na forum bodajże przez @scannera... Dla przypomnienia (nie znalazłem jej, więc nie podam linka):
<?php
//jest kilka moich zmian odnośnie zgodności z W3C
class content_manager
{
// ciach... (konstruktor, inne funkcje)
function bb2html($str)
{
'url' => Array('a','href=\"'), 'img' => Array('img', 'src=\"'), 'color' => Array('span','style=\"color:'), 'b' => 'font-weight: bold',
'u' => 'text-decoration: underline',
'i' => 'font-style: italic'
);
foreach( $codesArr as $aKey => $aVal)
{
$str = preg_replace_callback(\"#[($aKey)+[=]?(http|https|ftp+://)?(.*?)](http|https|ftp+://)?(.*?)[/$aKey]#si\", \"$this -> repl\", $str); };
return $str;
}
function repl($matches)
{
{
{
$protocol = $matches[2];
}
elseif (!empty($matches[4
])) {
$protocol = $matches[4];
}
else
{
$protocol = 'http://';
};
switch($matches[1])
{
case 'url':
$address = empty( $matches[3
] ) ?
$matches[5
] : $matches[3
]; $x = '<'.implode( ' ', $codesArr[$matches[1
]] ).$protocol.$address.'\">'.$matches[4
].$matches[5].'</'.$codesArr[$matches[1]][0].'>'; break;
case 'img':
$address = empty( $matches[3
] ) ?
$matches[4
].$matches[5
] : $matches[2
].$matches[3
]; $x = '<'.implode( ' ', $codesArr[$matches[1
]] ).$address.'\" alt=\"\" />'; break;
default:
$x = '<'.implode( ' ', $codesArr[$matches[1
]] ).$matches[3].'\">'.$matches[4
].$matches[5].'</'.$codesArr[$matches[1]][0].'>'; break;
}
}
else
{
$x = '<span style=\"'.$codesArr[$matches[1]].'\">'.$matches[5].'</span>';
}
return $x;
}
};
?>
o co teraz chodzi... chcę to wstawić w klasę... problem jest w tym, że gdy się do niej odwołuję (chcę przepuścić przez bb2html()) otrzymuję komunikat
Cytat
Warning: preg_replace_callback() requires argument 2, 'repl', to be a valid callback in C:\Serwer\Apache2\htdocs\doc\lbn\classes\content_manager.class.php on line 125 {tutaj linia 25-27}
Nie wiem, jak zmienić ten drugi argument w funkcji preg_replace_callback... wszystkie zmiany nic nie dają, próbowałem m. in. ze wstawieniem "$this -> repl", ale ciągle ten sam komunikat...
mam nadzieję, że jasno wytłumaczyłem (IMG:
http://forum.php.pl/style_emoticons/default/rolleyes.gif)
za wszelką pomoc z góry thx !