Hi!
For example, there is a script:
<?
echo some_function ($foobarbaz);
?>
This script returns string "foobarbaz".
What's the proper name of "some_function"?
Thanks!
Offer function, that returns variable's name.
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Offer function, that returns variable's name.
You can call the function whatever you want, as long as it is the same name when you define it!
i.e.
i.e.
Code: Select all
echo function1($var);
function function1($v) {
// do something
return $v;
}
- EverLearning
- Forum Contributor
- Posts: 282
- Joined: Sat Feb 23, 2008 3:49 am
- Location: Niš, Serbia
Re: Offer function, that returns variable's name.
Take a look at get_defined_vars function.
You'd call it from inside of your function to get the passed arguments.
And you get
Is that what you wanted?
You'd call it from inside of your function to get the passed arguments.
Code: Select all
test(4, 5, 6);
function test($first, $second, $third) {
var_dump(get_defined_vars());
}Code: Select all
array
'first' => int 4
'second' => int 5
'third' => int 6