Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Интернет » Web-программирование » Основы PHP...

Модерирует : Cheery

 Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

Открыть новую тему     Написать ответ в эту тему

karakurt2



Advanced Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
<?php
if ($_POST['submit']=="Submit")
{
    $arg1 = $_POST["LHS"];
    $arg2 = $_POST["RHS"];
    if (!empty($arg1) && !empty($arg2))
    {
        $descriptorspec =array(
            0=>array("pipe", "r"), // stdin is a pipe that the child will read from
            1=>array("pipe", "w"), // stdout is a pipe that the child will write to
            2=>array("file", "/tmp/adder-error.log", "a") // stderr is a file to write to
        );
         
        // $result=$arg1+$arg2;
        // echo "the answer is ".$result;        
        $process = proc_open("/var/www/cgi-bin/adder", $descriptorspec, $pipes);
        if (is_resource($process))
        {
            // $pipes now looks like this:
            // 0=>writable handle connected to child stdin
            // 1=>readable handle connected to child stdout
            // Any error will be appended to /tmp.adder-error.log
             
            fwrite($pipes[0], "$arg1 $arg2\n");
            fclose($pipes[0]);
             
            // $result = -1;
            // fscanf($pipes[1], " %d", $result);
            echo "the answer is ".  stream_get_contents($pipes[1]);
 
            fclose($pipes[1]);
            $return_value = proc_close($process);
        }
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form action="index.php" method="post">
            First argument:
            <input type="text" name="LHS" maxlength="50"><br />
            Second argument:
            <input type="text" name="RHS" maxlength="50"><br />
            Press to compute:
            <input type="submit" name="submit" value="Submit">
        </form>
    </body>
</html>
 

Всего записей: 733 | Зарегистр. 06-12-2003 | Отправлено: 10:11 17-11-2012 | Исправлено: karakurt2, 10:13 17-11-2012
Открыть новую тему     Написать ответ в эту тему

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Интернет » Web-программирование » Основы PHP...


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru