1

初めて PHP 拡張機能を作成しようとしています。連想配列を返す関数が必要です。したがって、テスト上の理由から、小さな関数を作成しました。

PHP_FUNCTION(testing_array) {
    char *firstVal = NULL;
    char *secondVal= NULL;
    int argc = ZEND_NUM_ARGS();
    int firstVal_len;
    int secondVal_len;

    if (zend_parse_parameters(argc TSRMLS_CC, "ss", &firstVal, &firstVal_len, &secondVal, &secondVal_len) == FAILURE)
        return;

    array_init(return_array);
}

しかし、コンパイルしようとするたびに、コンパイラは次のように伝えます。

/root/php/php-src/ext/hello_world/hello_world.c:87: error: return_array undeclared (first use in this function)
/root/php/php-src/ext/hello_world/hello_world.c:87: error: (Each undeclared identifier is reported only once
/root/php/php-src/ext/hello_world/hello_world.c:87: error: for each function it appears in.)

私が間違っていることは何ですか?私が見たすべての例で、配列変数は宣言されていません。

4

2 に答える 2

1

PHP_FUNCTION()マクロの定義を見てください。return_value 引数not を宣言していますreturn_array。そのため、後者は宣言されていません。

于 2013-08-29T23:51:25.690 に答える
0

エラーは非常に明確です。使用する前に変数を宣言する必要がありますreturn_array

于 2013-08-18T15:53:11.257 に答える