NYCPHP Meetup

NYPHP.org

[nycphp-talk] Thanks Eric Re: file -ib

Webapprentice . webapprentice at mail.com
Thu Jan 15 10:37:50 EST 2004


Thanks Eric for the code snippet.  I'll go to php.net and read up on the difference between exec() and system().

--Stephen


>>>Message: 8
Date: Wed, 14 Jan 2004 23:27:30 +0100
From: Eric Persson <eric at persson.tm>

Subject: Re: [nycphp-talk] file -ib? Re: Using
	$FILES["whatever"]["type"]	correctly
To: NYPHP Talk <talk at lists.nyphp.org>

Message-ID: <4005C252.2090303 at persson.tm>

Content-Type: text/plain; charset=us-ascii; format=flowed

Webapprentice . wrote:

> Eric,
> I'm not well-versed in UNIX.  How do I invoke a command-line
program in PHP?  Is there something like a system() call in some
other languages? 
> 
> --Stephen

Yes, sure is, I attached my function below:

function file_type($src){
	$exec = '/usr/bin/file -ib '.$src;
	exec($exec, $return);
	if( is_array($return) && isset($return[0]) ){
		return trim($return[0]);
	}else{
		return false;
	}
}

make sure to change the path to your file program, but I think this
is a 
somewhat standard place.

see the difference between system() and exec() and you'll see why I'm 
using exec().

//Eric
<<<<
-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm




More information about the talk mailing list