I need to use the same variables from a given function, in other different functions but with different variable values for each function in part.
In the following example I want to use some image parameters like "width", "height" and "alt" so that each image used in different functions have different parameters. Here's what I mean (pseudo codes):
function my_image_with_parameters() {
if first_function() { // pseudo if statement
$width = '350';
$height = '165';
$alt = 'Some alt';
} elseif second_function() { // pseudo elseif statement
$width = '600';
$height = '400';
$alt = 'Another alt';
}
return '<img src="http://someurl.com/image.png" width="' .$width . '" height="' .$height . '" alt="' .$alt . '" />';
}
function first_function() {
echo my_image_with_parameters();
}
function second_function() {
echo my_image_with_parameters();
}