'<a rel="nofollow" href="$1" class="bbc_link new_win" target="_blank">'
I would like use the urlencode()
function:
'<a rel="nofollow" href="urlencode($1)" class="bbc_link new_win" target="_blank">'
... but I can't use this:
'<a rel="nofollow" href="'.urlencode($1).'" class="bbc_link new_win" target="_blank">'
... because $1
is not a variable in the string; it is instead a meta-variable in a simple free forum.
it send http://www.test.com/out.php?out=http://www.example.com
There are two methods to call a function from string stored in a variable. The first one is by using the window object method and the second one is by using eval() method. The eval() method is older and it is deprecated.
In summary, to call a function from a string, the functions getattr() , locals() , and globals() are used. getattr() will require you to know what object or module the function is located in, while locals() and globals() will locate the function within its own scope.
The most basic example of a string function is the length(string) function. This function returns the length of a string literal. e.g. length("hello world") would return 11. Other languages may have string functions with similar or exactly the same syntax or parameters or outcomes.
To call a function from a string stored in a variable, use $func.
how about this crazy hack?
<?
$_ = 'urlencode';
echo "<a rel=\"nofollow\" href=\"{$_($1)}\" class=\"bbc_link new_win\" target=\"_blank\">";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With