PHP: Function call inside replace function
Linc
OwnerDetroit Icrontian
I need someone to explain how the hell this piece of code works (from vBulletin):
[PHP]$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $bbcode);
[/PHP]
Basically, it's finding a link pattern and replacing it with the RESULT of passing the match to the function handle_bbcode_url. However... that doesn't work. How can a function name be in the middle of a string and execute? I can't figure this POS out to save my life.
[PHP]$bbcode = preg_replace('#\[img\]\s*(https?://([^<>*"]+|[a-z0-9/\\._\- !]+))\[/img\]#iUe', "\$this->handle_bbcode_url(str_replace('\\\"', '\"', '\\1'), '')", $bbcode);
[/PHP]
Basically, it's finding a link pattern and replacing it with the RESULT of passing the match to the function handle_bbcode_url. However... that doesn't work. How can a function name be in the middle of a string and execute? I can't figure this POS out to save my life.
0
Comments
Functions can be layered into functions.
Eg.. str_replace(stripslashes(url_encode($some_value)));
It will always do the inner most function first. In this instance.. url_encode
According to that example, it should resolve itself somehow somewhere, but i can figure out why or where that it is.
???
In other news, I've pretty much decided eregi_replace is all-around worthless and does nothing but screw me up when I've used it.