What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



passthru — Executes command cmd in the system's command interpreter and displays the output. An optional argument allows the return value to be captured.


void passthru(cmd[, $return_value]);
string cmd: Command to be executed
variable $return_value (optional): Variable in which to store the return value of the command




passthru()() attempts to execute cmd in the system's command interpreter. PHP waits until the command interpreter returns before execution of the PHP script continues past the call to passthru() . If you're using a UNIX-like operating system, you can redirect stdout to a file or/dev/null to avoid this.

The output of the command will be sent directly tostdout.


PHP 3+; PHP 4+


Example 1098. Display the output of a random animated GIF generation script

// This script is for UNIX-like systems only

    Build an animated gif from a series of randomly selected images.
    Use a directory of incrementally numbered gifs (1.gif, 2.gif, etc..) as data for the animation.
    Use the excellent package gifsicle to join the images together.
    (The gifsicle homepage is located at
    Set up the script to allow the argument's delay and loopcount to be set from the query line.

    Note: This script can be called from an image tag. i.e:
    <a href="randimg.php?delay=1&loopcount=100" alt="This animation is a lot like a box of chocolates..." />

// Send an HTTP header describing the content that will be sent by the script
header ("Content-Type: image/gif");

// Convert the delay and loopcount arguments into unsigned integers
if (is_set ($delay))
    $delay = (int) abs ($delay);

if (is_set ($loopcount))
    $loopcount = (int) abs ($loopcount);
    $loopcount = 'forever';

// Seed the random-number generator
mt_srand ((double) microtime () * 1000000);

// Determine how many images to use in the animation
$amount = mt_rand (4, 24);

// Find out how many images are available using a combination of UNIX shell commands
// For more information on the ls and wc commands, please check your system's man pages
$total = `ls -1 *.gif | wc -l`;
    Note the backticks (`) enclosing the string in the previous instruction.
    PHP executes the contents of a backtick-delimited string as a shell command.
    Any output from the command that is sent to stdout will be returned.

// Choose an image at random
while ($no_of_images--)
    $image_list[] = mt_rand (1,$total) . '.gif';

// Convert the array of images into a string of arguments for a shell command
$image_list = implode (' ', $image_list);
    Note: The image names in $image_list are safe to use as shell arguments because
    they're not based on user input.

// Use passthru to print the verbatim output of gifsicle
passthru("gifsicle --careful --delay $delay --loopcount=$loopcount --optimize=2 $image_list");

PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.