I have a section of code that needs to be present in multiple places in one of vB's PHP files. Rather than duplicating the code, I thought that I would just make that common section into a function - and just call that function from the various places within the PHP file.
However, I don't seem to have done it properly. To test the process with just one of the locations, this is what I did:
I effectively started out with this:
PHP Code:
if ($_REQUEST['do'] == 'custom_action') {
// Common code was here
}
...and I made it this:
PHP Code:
function custom_function() {
// Common Code is now here
}
if ($_REQUEST['do'] == 'custom_action') {
custom_function();
}
However, that doesn't seem to work. Can someone help me to understand what I did wrong?