Nope, same problem.
If I pull out "php_execute_script(&script TSRMLS_CC);" and replace it
with, say, "zend_eval_string()", it works just fine. It's something with
the attempt to execute the script.
--->Ben
On 1/4/2016 1:39 PM, [email protected] wrote:
Didn't test but `argc;` should probably be `argc--;`.
Adam
On Mon, Jan 4, 2016 at 11:00 AM, Ben Trafford <[email protected]> wrote:
Hello!
I'm tinkering with embedding PHP, using Sara Golemon's book as a guide.
I'm using the following example from chapter 19.3:
#include <stdio.h>
#include <sapi/embed/php_embed.h>
int main(int argc, char *argv[])
{
zend_file_handle script;
/* Basic parameter checking */
if (argc <= 1) {
fprintf(stderr, "Usage: embed1 filename.php <arguments>\n");
return -1;
}
/* Set up a File Handle structure */
script.type = ZEND_HANDLE_FP;
script.filename = argv[1];
script.opened_path = NULL;
script.free_filename = 0;
if (!(script.handle.fp = fopen(script.filename, "rb"))) {
fprintf(stderr, "Unable to open: %s\n", argv[1]);
return -1;
}
/* Ignore argv[0] when passing to PHP */
argc;
argv++;
PHP_EMBED_START_BLOCK(argc,argv)
php_execute_script(&script TSRMLS_CC);
PHP_EMBED_END_BLOCK()
return 0;
}
It's tossing me a segfault, and the trace is coming back to a problem with
strlen(), which is usually indicative that something is being passed NULL
and shouldn't be.
I've narrowed down the issue to php_execute_script(). Now, Sara's examples
are a decade old, but I've looked at the guts of PHP, and can't find any
reason why that line should be problematic.
Any suggestions would be lovely.
PS: I've looked around for documentation on PHP's internals, but I can't
find any sort of class or function reference. Did I miss something obvious?
Thanks!
--->Ben
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
PECL development discussion Mailing List (http://pecl.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
PECL development discussion Mailing List (http://pecl.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php