funcion within a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mccommunity
Forum Commoner
Posts: 62
Joined: Mon Oct 07, 2002 8:55 am

funcion within a function

Post by mccommunity »

I have written a function and I have another function that I would like to execute within the first function. Can I do this with functions in php?
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Try it and find out......

Code: Select all

<?php
function FA()
{
$result = FB();
return $result;
}

function FB()
{
return "Hello";
}

echo(FA());
?>

I've never tried it so I can't give you an answer, but if you are starting to use functions within functions then it might be a good idea to learn how to use Classes instead.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Functions within functions does work - it is simplest (as Gen-ik pointed out) to test this sort of thing yourself.

Mac
Post Reply