News for hackers. Stuff that matters.
Re:Hello world in every programming language by lhnz on Sunday April 29, 2012 @08:19AM (#3905812)
Where do you learn such in depth information about PHP. The source code?
Re:Hello world in every programming language by rll on Sunday April 29, 2012 @10:47AM (#3906079)
It helps if you wrote a good chunk of it.

But one way that is easier than diving into the source code is to just dump the opcodes using vld (see pecl.vld). I have a little wrapper shell script /usr/local/bin/vld:

  #!/bin/sh -e
  exec php -dvld.active=1 -d vld.execute=0 "$@"
Then for the hello world program with the print() call:

  % vld hello1.php
  Finding entry points
  Branch analysis from position: 0
  Return found
  filename:       /tmp/hello1.php
  function name:  (null)
  number of ops:  3
  compiled vars:  none
  line     # *  op                           fetch            ext  return  operands
  ---------------------------------------------------------------------------------
     2     0  >   PRINT                                            ~0      'Hello+World'
           1      FREE                                                     ~0
     4     2    > RETURN                                                   1

  branch: #  0; line:     2-    4; sop:     0; eop:     2
  path #1: 0, 
vs. the one that just contains the string: Hello World

  % vld hello2.php
  Finding entry points
  Branch analysis from position: 0
  Return found
  filename:       /tmp/hello2.php
  function name:  (null)
  number of ops:  2
  compiled vars:  none
  line     # *  op                           fetch          ext  return  operands
  ---------------------------------------------------------------------------------
     2     0  >   ECHO                                                     'Hello+World%0A'
           1    > RETURN                                                   1

  branch: #  0; line:     2-    2; sop:     0; eop:     1
  path #1: 0,
Re:Hello world in every programming language by why-el on Sunday April 29, 2012 @11:37AM (#3906204)
Sorry to bother with an unrelated question, but how did you format the code pasted in your response?
Re:Hello world in every programming language by rll on Sunday April 29, 2012 @11:42AM (#3906219)
Re:Hello world in every programming language by why-el on Sunday April 29, 2012 @11:50AM (#3906240)
Thank you. I read that a while ago but I must have missed the section on code.