Jump to content

Help on usage


newbtophp

Recommended Posts

I'd like to make more reliable way of replacing function names (currently im using str_replace), theirfore I thought I could make a user defined function which is used exactly the same way as str_replace however it's dependency is token_get_all. (so it manipulates token_get_all to find a function [internal & userdefined] like the $search and replace all occurences of it)

 

So for example:

 

<?php
function replace_function($search, $replace, $code){
$tokens = token_get_all($code);
//proceed with complex code... 
}
$code = '<?php
deval("hey");
?>';

$code = replace_function('deval', 'echo', $code);

echo $code;

?>

 

All help is appreciated.

 

:-\

Link to comment
https://forums.phpfreaks.com/topic/196291-help-on-usage/
Share on other sites

Yes, As you'll see in any professional code samples (IE very large CMSs, Boards), They use their own namespaces or function prefexes. (Sometimes only but an underscore ("_") is needed before the function name if you're not sure what functions may be intercepted by your naming convention).

Link to comment
https://forums.phpfreaks.com/topic/196291-help-on-usage/#findComment-1030781
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.