# Determine the name of the PHP SAPI module.

- Thread: https://externals.io/message/51759
- Original archive: https://news-web.php.net/php.internals/51759
- Started by Richard Quadling on 2011-03-31T09:24:08+00:00
- Messages: 3
- 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

---

## #51759 — Richard Quadling — 2011-03-31T09:24:08+00:00

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

Hi.

From a CLI/CGI perspective, the following code returns the full path
of the php.exe file.

		DWORD len;
		char buf[MAX_PATH];

		len = GetModuleFileName(NULL, buf, sizeof(buf));
		buf[len] = '\0';


If PHP is loaded as a module, how do you determine the filename of the
module. I'm guessing the above code would return Apache or IIS (if
using ISAPI), etc.

Is there a global property available for this (or for the above code)?

Richard.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

---

## #51760 — Rasmus Lerdorf — 2011-03-31T09:31:28+00:00

URL: https://externals.io/message/51759#51760 · In reply to: #51759

#include "SAPI.h"

and then you will have the name in the global sapi_module struct:

sapi_module.name

-Rasmus


> Hi.
> 
> From a CLI/CGI perspective, the following code returns the full path
> of the php.exe file.
> 
> 		DWORD len;
> 		char buf[MAX_PATH];
> 
> 		len = GetModuleFileName(NULL, buf, sizeof(buf));
> 		buf[len] = '\0';
> 
> 
> If PHP is loaded as a module, how do you determine the filename of the
> module. I'm guessing the above code would return Apache or IIS (if
> using ISAPI), etc.
> 
> Is there a global property available for this (or for the above code)?
> 
> Richard.

---

## #51761 — Richard Quadling — 2011-03-31T10:06:49+00:00

URL: https://externals.io/message/51759#51761 · In reply to: #51760

> #include "SAPI.h"
>
> and then you will have the name in the global sapi_module struct:
>
> sapi_module.name
>
> -Rasmus
>
> 
> > […]

Thank you.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY
