# PHP version and Zend API Number

- Thread: https://externals.io/message/28476
- Original archive: https://news-web.php.net/php.internals/28476
- Started by Michael B Allen on 2007-03-20T00:16:18+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #28476 — Michael B Allen — 2007-03-20T00:16:18+00:00

URL: https://externals.io/message/28476#28476

Hi,

Is there a way to get the version of the PHP binary that loaded an
extension from within the extension? I don't mean the PHP version the
extension was compiled with (PHP_VERSION), I mean the version of the
PHP binary itself?

Can I call the phpversion function from within an extension?

Similarly is there a way to get the zend API version of the PHP binary
(not the version the extension was compiled with)?

Mike

-- 
Michael B Allen
PHP Active Directory SSO
http://www.ioplex.com/

---

## #28479 — Michael Wallner — 2007-03-20T12:17:24+00:00

URL: https://externals.io/message/28476#28479 · In reply to: #28476

Michael B Allen wrote:
> Hi,
> 
> Is there a way to get the version of the PHP binary that loaded an
> extension from within the extension? I don't mean the PHP version the
> extension was compiled with (PHP_VERSION), I mean the version of the
> PHP binary itself?
> 
> Can I call the phpversion function from within an extension?
> 
> Similarly is there a way to get the zend API version of the PHP binary
> (not the version the extension was compiled with)?

mike@honeybadger:~/cvs/php-5.2$ grep -E 'version.*\);' Zend/*.h
Zend/zend_API.h:ZEND_API char *zend_get_module_version(char *module_name);
Zend/zend_extensions.h:void zend_append_version_info(zend_extension *extension);
Zend/zend.h:ZEND_API char *get_zend_version(void);


You could query ext/standard for the PHP version, everything else should be self explanatory. 

Regards,
-- 
Michael

---

## #28509 — Michael B Allen — 2007-03-21T02:15:47+00:00

URL: https://externals.io/message/28476#28509 · In reply to: #28479

On Tue, 20 Mar 2007 13:17:24 +0100
Michael Wallner <mike@php.net> wrote:

> Michael B Allen wrote:
> > […]
> 
> mike@honeybadger:~/cvs/php-5.2$ grep -E 'version.*\);' Zend/*.h
> Zend/zend_API.h:ZEND_API char *zend_get_module_version(char *module_name);
> Zend/zend_extensions.h:void zend_append_version_info(zend_extension *extension);
> Zend/zend.h:ZEND_API char *get_zend_version(void);
> 
> 
> You could query ext/standard for the PHP version, everything else should be self explanatory. 

Yes, that does give me the PHP version. Thanks.

The get_zend_version function returns a string like 'Zend Engine v1.3.0,
Copyright (c) 1998-2004 Zend Technologies\n'. It would be nice to be
able to get the ZEND_MODULE_API_NO (e.g. 20060613) the standard module
was compiled under.

I'm still confused about how many versions of extensions I need to provide
with my product. Currently I just compile it against late versions of 4,
5.0, 5.1 and 5.2 and hope for the best. But looking at ZEND_MODULE_API_NO
changes in webcvs shows it changes more frequently than that.

But so far I haven't ran into major problems with ZEND_MODULE_API_NO
so maybe I'm just being paranoid. From looking at zend.c it looks like
it will print diagnostic info if some tries to load an incompatible
extension.

Mike

-- 
Michael B Allen
PHP Active Directory Kerberos SSO
http://www.ioplex.com/

---

## #28512 — Michael Wallner — 2007-03-21T08:27:10+00:00

URL: https://externals.io/message/28476#28512 · In reply to: #28509

Michael B Allen wrote:

> The get_zend_version function returns a string like 'Zend Engine v1.3.0,
> Copyright (c) 1998-2004 Zend Technologies\n'. It would be nice to be
> able to get the ZEND_MODULE_API_NO (e.g. 20060613) the standard module
> was compiled under.

basic_function_module.zend_api might be what you're looking for.

> I'm still confused about how many versions of extensions I need to provide
> with my product. Currently I just compile it against late versions of 4,
> 5.0, 5.1 and 5.2 and hope for the best. But looking at ZEND_MODULE_API_NO
> changes in webcvs shows it changes more frequently than that.
> 
> But so far I haven't ran into major problems with ZEND_MODULE_API_NO
> so maybe I'm just being paranoid. From looking at zend.c it looks like
> it will print diagnostic info if some tries to load an incompatible
> extension.

It looks like that:

mike@honeybadger:~$ php -n -dextension_dir=/usr/local/lib/php/extensions/no-debug-non-zts-20050922/ -dextension=ffi.so -v
PHP Warning:  PHP Startup: ffi: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP    compiled with module API=20060613, debug=0, thread-safety=1
These options need to match


-- 
Michael
