Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.