Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7683589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:49:43+00:00 2026-05-31T18:49:43+00:00

I’m dabbling with creating a PHP extension for a personal project. Beyond what’s linked

  • 0

I’m dabbling with creating a PHP extension for a personal project. Beyond what’s linked in the above article I have no knowledge of the zend_engine, and my C skills are 10 years out of date, and were only ever academic. All of which is to say “If it seems like I’m asking a dumb question, I probably am”.

Is it possible to call functions from other PHP extensions in my own extension, or is each PHP extension considered an island, with no insight into other parts of the system? If this is possible, is it common practice, or a Bad Idea™?

That is, I know I can return a string with something like this.

PHP_FUNCTION(hello_world)
{
    char *str;
    str = estrdup("Hello World");
    RETURN_STRING(str, 0);
}

I’d like to be able to return, say, a SimpleXML element, or a DomDocument element. Googling has proven difficult, as there’s not a ton out there about extension development, and there IS a ton out there about standard PHP usage.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:49:44+00:00Added an answer on May 31, 2026 at 6:49 pm

    Yes, extensions can in fact depend on others. They can:

    • Use resources that other extensions register globally, such as class types or PHP functions (that is, they don’t have less access than user-land scripts, which can obviously use those resources). See zend_call_function and zend_lookup_class_ex.
    • Use any exported symbols and structures that are declared in the file php_extensionname.h (these headers are the only ones that are considered to a export a native API to other extensions). However, some extensions may in fact NOT export some symbols declared in those header files, you must look for symbols declared with PHPAPI. Note that some extensions cannot be deactivated and you can rely on them being present (for instance, as of 5.3/5.4, standard, SPL, reflection, date, pcre, ereg).
    • If both your extension and target extension are built statically, you have of course more latitude on the symbols you can use, but it’s not a good practice to use non-exported symbols.

    I’d like to be able to return, say, a SimpleXML element, or a DomDocument element.

    If you need to explicitly instantiate a SimpleXMLElement or a DOMDocument, you can do so with object_init_ex. Extensions usually export the zend_class_entry * that have to pass that macro, but if not you can always use zend_lookup_class_ex. This does NOT call the constructor, so you still must do so manually if you need to.

    Some extensions may provide a native interface to instantiate and initialize an object, but in general extensions are not prepared to have other extensions instantiate their types.

    Of course, you can also, like a script, call PHP functions and methods that return any of those types. You’ll get a zval * that you can in turn return from your function.

    As to how to declare the dependencies, the extension descriptor has an entry for this. This will ensure your extension is loaded after the ones you declare you depend on. For declaring the dependency at compile time see PHP_ADD_EXTENSION_DEP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.