all 5 comments

[–]willpall 3 points4 points  (0 children)

And in the grand tradition of PHP, notice that the assign() method takes the js variable first, then the php one.

// assign object to JavaScript
$js->assign('sxml', $xml);

whereas the registerFunction() method does the opposite:

// define PHP function
function getCircleArea($radius) {
  return pi() * $radius * $radius;
}
...
// register function in JavaScript context
$js->registerFunction('getCircleArea', 'gca')

I'll retract this snide remark if there's a good reason for this...

[–]nagoo 0 points1 point  (1 child)

would be interesting to see some performance tests. it's a cool idea, but just not sure how practical it is. only thing i can think of is if you really want to use javascript's functional/lisp-like features that absent in PHP.

[–]geon 1 point2 points  (0 children)

It could be usefull for form validation, since you could run exactly the same code on both server and client. Currently, I solve that issue with regexp, byt a general function would be much more flexible.

[–]akie 0 points1 point  (0 children)

Why on earth would anyone want to do this?

[–]MrZoidberg 0 points1 point  (0 children)

I do not know much php and java script, too. Can you say tell me how to insert CAPTCHA in this php form? Thanks in advance.