Executing External Programs

Executing  External Programs

We can execute external programs using PHP
That may be usefull for some situation

the backtick operator (`),
which can be used to run an external program from within a PHP script.
PHP uses exactly the same technique: simply enclose the command line to your external program within backticks inside a PHP script, and PHP will launch the external program when it reaches that line of code.
following code hows you how a backtics can be used

< ?php
`ls -l`;
? >

Of course, this is fairly useless by itself; in most cases, you will want to import the output of the external program into your PHP script for further processing. Fortunately, that’s simple — all you do is treat the backtick-enclosed code as a regular PHP variable and display it using echo() or print().

We can also user

exec() and passthru()
which execute the external program and gives us raw output.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.