I have a custom C extension loaded in my PHP and inside the extension there's a function does something like this
void a() {
printf("abc");
}
I can call a()
with no problem in CLI mode (command-line) and got the output abc
as expected. But when i tried again in our Yii project in PHP-FPM mode,I couldn't get that output.
What I am sure about is:
ob_end_clean()
twice before calling a()
, the first call return true
and the second returned false
.So my question is:
Am I supposed to get output from extensions in PHP-FPM mode?
If so, how can I capture the output, or please shoot me some debugging advice.
When PHP runs as a webserver module, stdout is redirected to the terminal from which the webserver process was originally started. On production server such a terminal is not active, so any output that you send to stdout will be lost.
try php_printf() function istead of printf() one
probably this article can help you https://devzone.zend.com/317/extension-writing-part-ii-parameters-arrays-and-zvals/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With