Having said that, you shouldn’t be echoing html from within your functions. Your functions should just have logic in them, and the html should be outside of the functions. It’ll make your code more flexible and easier to change in the future.
Can you provide more clarity? What exactly do you mean a “function inside a function”?
For example, there are a few issues with your code, popup will always use “” for $html_translation_id and $language_id for one, unless you pass them to that function or declare them global, but I don’t think that is what you are asking for…
// give lang id a default value
function get_html_translation ($html_translation_id, $language_id = 1) {
// set the default value for html here ....
$html = '<p>[no_data]</p>';
// if lang id is not set, it is now set to 1
$query = "SELECT html_text FROM html WHERE html_translation_id = '$html_translation_id' AND language_id = '$language_id'";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
// do you really have more than one result, ever?
// if so, you only ever get the last one ....
if ($rows > 0) {
while ($array = mysql_fetch_assoc($result)) {
$html = $array['html_text'];
}
}
// if that lot was NOT instantiated, then your default html value will fall through to here ...
return $html;
}
From the two lines “return $popup” and “$popup = popup()”, I get the impression the OP is attempting to use inline / anonymous methods. In most cases, the inline method is defined within the scope of the calling method, not outside. The reason of course is to keep scope local to the calling function. Having it outside the calling function is pointless. You may as well make it a regular function. Here’s a good page on the subject.
That’s because the parameters that popup passes to get_html_translation are always going to be blank. (cpradio already mentioned that a couple days ago, btw.) If popup is going to use global variables (which is a bad idea, but…) then those variables need to be declared with the global keyword.