You haven't included anywhere near enough information to get an answer.
You need to show all the class definitions etc.
Also how is this supposed to intergrate, you can't just swap out a small part of a c++ app with some php code.
Will the whole app be rewriten in php or will you exec() the php as an app from your c++ app.
A general description of what the code is doing will also help.