I have script which has the following structure:
<?php
if( a == b ){
function some_function_name(){
// do something here
}
if( c == d ){
some_function_name();
}
}
?>
I get an error message saying that some_function_name(); does not exist.
What am I doing wrong and is this good practice?
I want to create a function, because I have a bunch of steps which I need to use many times, and I would prefer not to have to copy/paste the same code over and over again.
I would avoid defining the function inside a conditional
if()statement. Define the function first, at the top of the file and call it when necessary.