callback syntax not valid in phalanger tools for VS
7 posts
• Page 1 of 1
callback syntax not valid in phalanger tools for VS
Hi there,
The following syntax is not valid neither for Phalanger nor PHP using the Phalanger Tools for VS (for VS2012) version 3.0.4069.
The error is:
Syntax error: unexpected token 'myCallbackFunction'
Is the same for either PHP or Phalanger Console Application project.
Is this a bug in the PHP tools or are PHP callbacks not supported?
Thanks
Carlos
The following syntax is not valid neither for Phalanger nor PHP using the Phalanger Tools for VS (for VS2012) version 3.0.4069.
- Code: Select all
<?php
echo "Hello World!\n";
fgets(STDIN);
$callback = function myCallbackFunction()
{
echo "callback achieved";
}
call_user_func($callback);
?>
The error is:
Syntax error: unexpected token 'myCallbackFunction'
Is the same for either PHP or Phalanger Console Application project.
Is this a bug in the PHP tools or are PHP callbacks not supported?
Thanks
Carlos
- carlosqt
- Posts: 7
- Joined: March 10th, 2013, 7:21 pm
Re: callback syntax not valid in phalanger tools for VS
Hi Carlos!
I've checked this syntax with regular PHP (5.4.0), and it does not seem to support such syntax either.
Anonymous functions do not need the function name (http://php.net/manual/en/functions.anonymous.php).
Is it correct?
Thanks!
I've checked this syntax with regular PHP (5.4.0), and it does not seem to support such syntax either.
Anonymous functions do not need the function name (http://php.net/manual/en/functions.anonymous.php).
Is it correct?
Thanks!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: callback syntax not valid in phalanger tools for VS
Thanks for the quick answer Jakub,
If I remove the function name it works fine thanks!
I will just remove those names whenever I see code like the one with function name.
I'm following a PHP book called "Programming PHP 3rd Edition from O'Reilly" and it seems to be based on version 5.x because of the following statements:
"This book has been fully revised to cover the latest features of PHP version 5."
"As this book goes to press, PHP version 5.4 has been released for some time."
Here below other 3 code examples using that syntax (which includes the function name), however, there is also an example of Anonymous Functions and those do not have function name...
If I remove the function name it works fine thanks!
I will just remove those names whenever I see code like the one with function name.
I'm following a PHP book called "Programming PHP 3rd Edition from O'Reilly" and it seems to be based on version 5.x because of the following statements:
"This book has been fully revised to cover the latest features of PHP version 5."
"As this book goes to press, PHP version 5.4 has been released for some time."
Here below other 3 code examples using that syntax (which includes the function name), however, there is also an example of Anonymous Functions and those do not have function name...
- Code: Select all
$callback = function printRow($value, $key)
{
print("<tr><td>{$value}</td><td>{$key}</td></tr>\n");
};
$person = array('name' => "Fred", 'age' => 35, 'wife' => "Wilma");
array_walk($person, $callback);
$callback = function addItUp($runningTotal, $currentValue)
{
$runningTotal += $currentValue * $currentValue;
return $runningTotal;
};
$numbers = array(2, 3, 5, 7);
$total = array_reduce($numbers, $callback);
$callback = function isOdd ($element)
{
return $element % 2;
};
$numbers = array(9, 23, 24, 27);
$odds = array_filter($numbers, $callback);
- carlosqt
- Posts: 7
- Joined: March 10th, 2013, 7:21 pm
Re: callback syntax not valid in phalanger tools for VS
It is weird, since it seams it is not valid PHP syntax. Maybe some future feature?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: callback syntax not valid in phalanger tools for VS
Yes, is probably that.
Never mind then and thanks for the clarification.
Carlos
Never mind then and thanks for the clarification.
Carlos
- carlosqt
- Posts: 7
- Joined: March 10th, 2013, 7:21 pm
Re: callback syntax not valid in phalanger tools for VS
May I ask how does it involve Phalanger Tools? Is there any more information?
- erum
- Posts: 1
- Joined: November 25th, 2013, 5:51 am
Re: callback syntax not valid in phalanger tools for VS
Phalanger Tools support the syntax you actually have in currently installed version of Phalanger.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
7 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests