So is this print function inbuilt to the PHP v8 extension? It's not declared, also.. what a crazy example
On Thu, Mar 15, 2012 at 2:55 PM, Isaac Schlueter <[email protected]> wrote: > The string being stored to $JS is valid javascript. > > len = print('Hello' + ' ' + 'World!' + "\n"); > len; > > JavaScript programs evaluate to their completion value (the expression > value of the last statement). The `print()` on its own would have the > same result, so the `len` global is unnecessary, but then again, so > are the semicolons and the excessive string concatenation ;) > > The same example in js: > > function print (m) { console.log(m) ; return m.length } > var JS = 'len = print(\'Hello\' + \' \' + \'World!\' + "\\n");\nlen;' > var res = eval(JS) // or vm.runIn...() in node.js > console.log('result=', res) > > > On Wed, Mar 14, 2012 at 21:24, Dave Clements > <[email protected]> wrote: > > Yah that's what I thought, they haven't used var, and the line with > len; on > > it's own is supposed to return int(13). > > > > I suppose I just wanted to confirm whether this example really was as > > clueless as it seems > > > > On Thursday, 15 March 2012 03:33:02 UTC, Matt wrote: > >> > >> I think the issue here is that it doesn't appear to be valid JavaScript > at > >> all. Or at the very least, it's fairly non-sensical (i.e., execute a > print > >> statement, which we can only assume is defined for V8Js, store the > return > >> value [probably undefined?] to a variable, and then "return" that > variable). > >> > >> -Matt > >> > >> On Mar 14, 2012, at 11:35 PM, Matthew Vickers wrote: > >> > >> This seems to be PHP pushing Javascript through V8. > >> > >> $JS is a here doc containing some javascript code. > >> > >> Matt > >> > >> ----- "Dave Clements" wrote: > >> > This is a "Javascript" example from the PHP v8 extension > >> > >> > > >> http://www.php.net/manual/en/v8js.examples.php > >> > > >> > >> > > >> <?php > >> > > >> > $v8 = new V8Js(); > >> > > >> > /* basic.js */ > >> > $JS = <<< EOT > >> > len = print('Hello' + ' ' + 'World!' + "\\n"); > >> > len; > >> > EOT; > >> > > >> > try { > >> > var_dump($v8->executeString($JS, 'basic.js')); > >> > } catch (V8JsException $e) { > >> > var_dump($e); > >> > } > >> > > >> > ?> > >> > > >> > >> > > >> > >> > > >> I know this isn't Node, but I just wanted to check I'm not mad... the > $JS > >> variable.. that's not javascript at all is it? Or have I completely > >> misunderstood v8? > >> > >> -- > >> > Job Board: http://jobs.nodejs.org/ > >> > Posting > >> > guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > >> > You received this message because you are subscribed to the Google > >> > Groups "nodejs" group. > >> > To post to this group, send email to [email protected] > >> > To unsubscribe from this group, send email to > >> > [email protected] > >> > For more options, visit this group at > >> > http://groups.google.com/group/nodejs?hl=en?hl=en > >> > > >> > >> -- > >> Job Board: http://jobs.nodejs.org/ > >> Posting > >> guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > >> You received this message because you are subscribed to the Google > >> Groups "nodejs" group. > >> To post to this group, send email to [email protected] > >> To unsubscribe from this group, send email to > >> [email protected] > >> For more options, visit this group at > >> http://groups.google.com/group/nodejs?hl=en?hl=en > >> > >> > > -- > > Job Board: http://jobs.nodejs.org/ > > Posting guidelines: > > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > You received this message because you are subscribed to the Google > > Groups "nodejs" group. > > To post to this group, send email to [email protected] > > To unsubscribe from this group, send email to > > [email protected] > > For more options, visit this group at > > http://groups.google.com/group/nodejs?hl=en?hl=en > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
