0

I am trying to code PHP extensions in C++. I am referring 'Embedding and Extending PHP' by Sara Golemon.

The book has several small snippets as such,

void describe_zval(zval *foo)
{
    if (Z_TYPE_P(foo) == IS_NULL) {
        php_printf("The variable is NULL");
    } else {
        php_printf("The variable is of type %d",
                            Z_TYPE_P(foo));
    }
}

I have saved the above code in .cpp

The struct zval etc is defined in files in /usr/local/src/php-5.4.11/ and its sub -directories. That is the installation directory of PHP on my PC [Fedora]. So I tried

#include <zend.h>

and used -I /usr/local/src/php-5.4.11/ while compiling. But zend.h seems to require some other file present in /usr/local/src/php-5.4.11/ directory. If i #include that it requires some others and so on... Basically a chain of .h is being called which resides in several different sub directories of /usr/local/src/php-5.4.11/ . Its not possible for me to #include all of them. Is there any existing library for this? using Zend variables for PHP extension development using Cpp

Is there a better way to do this? I mean is there a better way to practise those small snippets before i jump into the whole extension development.

2
  • 1
    Perhaps using phpize will be useful? Commented Mar 14, 2013 at 11:43
  • @Waleed Khan: Thnks, Ohkk so i need to use phpize. Yes, dat makes sense :) after all what I am doing is writing a small snippet for a PHP extension. Have been thinking in the wrong direction the whole time :P Commented Mar 14, 2013 at 11:53

1 Answer 1

1

have you looked at the ext-skel directory? there should be a script there to generate an extension skelleton which should get you started.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeps that would be helpful too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.