Re: Obtaining data from external programs
| From: | Matt McClanahan | Date: | Wed, 29 Nov 2000 00:08:29 +0000 |
| Subject: | Re: Obtaining data from external programs | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-27707@lists.php.net to get a copy of this message | ||
On Tue, 28 Nov 2000, Rudy Aceves wrote:
> My first thought was just to write a simple CGI program that encapsulated
> the shared lib then just spit out its own HTML. But I want the flexibility
> of the scripting and there is some other cool PHP functionality that I want
> to
> use (or don't want to reinvent).
>
> So I wondering if it is possible to access a SUN shared lib directly from a
> PHP
> script?
There isn't, no.
> If not, what would maybe be an alternative? Write a small wrapper program
> that pull
> out the values I wanted then have PHP execute the program?
> But how could I get the data back into the script? Possibly through file i/o
> but the
> exec / file write, read and delete sounds kinda expensive?
Well, you could write a PHP extension that linked against the library in
question, and provided an interface to the library's API. But a faster
option may be to write an external program that you could exec() from
inside PHP. That external program could output XML, or some other flat
data to be parsed from within the PHP script.
Whether you write an external program or a PHP extension is mainly a
question of if this is the only use you'll have for the library, or if it
would benefit you in scripts down the road. If this is a one time thing,
I'd lean towards just writing up a quick external app. But if the library
has features that could be used in a variety of ways, I'd look into
writing an extension.
Matt