Link to home
Start Free TrialLog in
Avatar of pmsguy
pmsguy

asked on

How does my PHP script know if it is run by a browser or command line?

I want my php script to know if it is run by the browser or by the command line.

How do I tell the difference?

argv==NULL means browser?
ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@davbladwin - PHP is now becoming popular to run  command line as well as on a server
@chilternPC, yes i know.  I have some text processing utilities running PHP from the command line on this computer.  @pmsguy just wants to be able to tell the difference.
Avatar of dockhand
dockhand

It is a matter of symantics, but what I think DaveBaldwin is trying to say that no matter how it is envoked Php is what would be condidered Server Side in a Client-Server app.  Even if envoked by command line it is running on the server and merely feeding the client.

What I think pmsguy is wanting to know is how was the server side code envoked?  You guys both  have already given him tools to ascertain this information.