PHP_FUNCTION(hello_world) {
char *string;
int s_len;
char *output_string = "You've entered: ";
char *str;
char newS[100];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &s_len) == FAILURE) {
RETURN_FALSE;
}
strcat(newS, output_string);
if (s_len + strlen(newS) + 1 > sizeof(newS)) {
RETURN_STRING("Your string is too long", 1);
}
strcat(newS, string);
// str = estrdup(newS);
RETURN_STRING(newS, 1);
}
/*
after compilation, when I execute
<?php
echo hello_world("Some string");
?>
the output is "lOYou've entered: some string" without the quotes. The left two bytes are different when the "Some String" is changed.
*/