PHP Velho Oeste 2024

İşlevlerin Yazılması

PHP bir yapıştırıcı dil olarak da bilinir ve eklentiler sayesinde kolayca genişletilebilir. C işlev arayüzü üretmek için bir prototip dosyası ve ext_skel betiğini kullandığınızda oluşturduğunuz işlevleri küresel hale getirmek için şöyle bir basit prototipin yeterli olduğunu farkedeceksiniz: PHP_FUNCTION(işlev_ismi)

add a note add a note

User Contributed Notes 2 notes

up
5
ka5 at ua dot fm
4 years ago
The 'l' spec expects a parameter of the type zend_long, not long anymore.
The 's' spec expects parameters of the type char * and size_t, no int anymore.
(c) https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING.INTERNALS#L75
up
1
Anton
4 years ago
To handle string parameters you should specify string length:

char *s1;
size_t s1_len;

char *s2;
size_t s2_len;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss",
                          &l, &s1, &s1_len, &s2 &s2_len)  != SUCCESS) {
    return;
}
To Top