Get all $vars from 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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Get all $vars from a function()

Post by Gen-ik »

Does anyone know if it's possible to get a list of all the variables in a function() regardless of if they were predefined of dynamically created?

Code: Select all

<?php
// An example.

function EatVars()
{
    $a = "apple";
    $b = "banana";
    ${$a} = "{$a} pie";
}

$allVars = somehow_get_all_vars_from_EatVars_into_an_array;

echo count($allVars);
?>
It would be very handy to know.
Post Reply