• 0

Unset a function?


Question

Is there a way in PHP to unset/delete a function that's already been made, so that I can reuse the name?

Reason is because in vbulletin3.5 there's the plugin system which i want to use to edit a function but there's no hooks in that function,so what i want to do is just copy/paste the code, make my edits, and put it into a plugin that cmes after the function has been made. Problem with just creating it is that i get the function already exists cannot redeclare message.

Thanks. :)

Link to comment
https://www.neowin.net/forum/topic/392084-unset-a-function/
Share on other sites

10 answers to this question

Recommended Posts

  • 0
Or just make your edits directly into the VB function

586756679[/snapback]

I'm trying to keep the forum file-edit free for ease of upgrading...

This is the only file edit the forum has atm, i'm just trying to make it into a plugin so there will be none to worry about.

  • 0
You can use rename_function

<?php
rename_function('original_name', 'new_name' );
?>

and then redeclare the original function.

override_function may work too.

Info:

override_function

rename_function

586761508[/snapback]

I tried rename_function. Here is the code I used:

//Rename the old function
rename_function('strip_quotes','strip_quotes_non_nested');

But then I get this messsage on the forums:

Fatal error: Call to undefined function: rename_function() in /home/filesh/filesharingtalk.com/html/vb3/global.php(233) : eval()'d code on line 156

:(

  • 0

You might be able to use the method below, as described on: http://www.experts-exchange.com/Web/Web_La...Q_21615087.html

You can indeed call functions dynamically:

function function1(){
 echo "1";
}

function function2(){
 echo "2";
}

$i = "function2";
$i(); //  displays 2;

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.