'<a rel="nofollow" href="$1" class="bbc_link new_win" target="_blank">'
我想使用这个urlencode()功能:
 '<a rel="nofollow" href="urlencode($1)" class="bbc_link new_win" target="_blank">'
......但我不能用这个:
 '<a rel="nofollow" href="'.urlencode($1).'" class="bbc_link new_win" target="_blank">'
...因为$1不是字符串中的变量; 它是一个简单的免费论坛中的元变量.
它发送 http://www.test.com/out.php?out=http://www.example.com
这个疯狂的黑客怎么样?
<?
$_ = 'urlencode';
echo "<a rel=\"nofollow\" href=\"{$_($1)}\" class=\"bbc_link new_win\" target=\"_blank\">";
看看这个技巧:
function foo() { return "title"; }
$func = function($param) { return $param; };
$link = 'http://www.test.com/out.php?out=http://www.example.com';
echo "<a rel=\"nofollow\" href=\"{$func(urlencode($link))}\" class=\"bbc_link new_win\" target=\"_blank\">{$func(foo())}</a>";
$func()将作为函数调用,并且括号中的表达式将像任何其他 PHP 代码一样进行计算。