Jump to content

Functional programming


keenlearner

Recommended Posts

I need to do a few functional programming in PHP, here is the code but it only prints out "arg2" but not "arg1". Thank you.

 

function prints($arg1, $arg2)
{
  echo $arg1. $arg2;
}


function applyOne($arg1)
{
  $f =  create_function('$arg2', 'return prints("$arg1", $arg2);');
  return $f;
}

$printFunction = applyOne("arg1");

$printFunction('arg2');

Link to comment
https://forums.phpfreaks.com/topic/83830-functional-programming/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.