I am trying to create an embedded application that executes arbitrary PHP scripts. If the script is syntactically correct, all works as desired. However, if there is a syntax error, I don't get any error text that I can return or log, etc. zend_eval_string does indeed return a -1 if there is a problem, 0 otherwise. So at least I know something failed.

I am using PHP 5.1.4 on Linux.

My code:

 char *argv[] = {const_cast<char *>(input.c_str())};
 int argc(1);

 std::ostringstream scriptOutputStream;
 std::ostringstream scriptErrorStream;

 P2PCrud::phpWriteStream_ = &scriptOutputStream;
 P2PCrud::phpErrorStream_ = &scriptErrorStream;

 php_embed_module.ub_write = P2PCrud::phpWrite;
 php_embed_module.log_message = P2PCrud::phpErrors;

#ifdef ZTS

 void ***tsrm_ls;
#endif

 php_embed_init(argc, argv PTSRMLS_CC);

 zend_first_try
 {
    int rc(0);

    rc = zend_eval_string(const_cast<char *>(script.c_str()),
                          0,
                          "Embedded code" TSRMLS_CC);
    std::cout << "end of 'zend_first_try' block, rc = " << rc << "\n";
 }
 zend_end_try();

 php_embed_shutdown(TSRMLS_C);

 output = scriptOutputStream.str();

 std::cerr << "error stream = " << scriptErrorStream.str() << "\r\n";
 P2PCrud::phpWriteStream_ = 0;
 P2PCrud::phpErrorStream_ = 0;

Thanks in advance,

Bruce

_________________________________________________________________
Get today's hot entertainment gossip  http://movies.msn.com/movies/hotgossip

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to