0

バックグラウンドでphpスクリプトを開始したいのですが、このコードを実行しています

<?php
while(true){
$commandString = 'start /b C:\xampp\php\php.exe  "C:\xampp\htdocs\caliban\blobs.php"'; 
popen($commandString, 'r'); 
sleep(5);
}
?>

バックグラウンドで実行されているタスクを停止せずに、このコードを実行して Web ブラウザの読み込みを停止するにはどうすればよいですか?

blobs.php

<?php

//pdo connect function
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}

//third function
$firstname = rand(4,4);
$lastname = rand(4,4);
$city = rand(4,4);
$continent = rand(4,4);
$profile = rand(4,4);
$image = rand(4,4);
$sql = "INSERT INTO mymodels ".
       "(firstname,lastname,city,continent,image,profile) ".
       "VALUES ".
       "('$firstname','$lastname','$city','$continent','$image','$profile')";
mysql_select_db('caliban');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not enter data: ' . mysql_error());
}



?>

SQL

create table mymodels(
   id INT NOT NULL AUTO_INCREMENT,
   firstname VARCHAR(100) NOT NULL,
   lastname VARCHAR(40) NOT NULL,
   city VARCHAR(40) NOT NULL,
   continent VARCHAR(40) NOT NULL,
   image BLOB,
   profile VARCHAR(400) NOT NULL,
   PRIMARY KEY ( id )
);
4

2 に答える 2

1
function close_connection(){
    ob_end_clean();
    header("Connection: close");
    ignore_user_abort(); // optional
    ob_start();
    $size = ob_get_length();
    header("Content-Length: $size");
    ob_end_flush();
    flush();
}

それで

<?php
    close_connection();
    while(true){
        $commandString = 'start /b C:\xampp\php\php.exe  "C:\xampp\htdocs\caliban\blobs.php"'; 
        popen($commandString, 'r'); 
        sleep(5);
    }
?>
于 2013-06-10T08:01:11.927 に答える
0

これを行う

<?php
function close_connection(){
    ob_end_clean();
    header("Connection: close");
    ignore_user_abort(); // optional
    ob_start();
    $size = ob_get_length();
    header("Content-Length: $size");
    ob_end_flush();
    flush();
}
close_connection();
exec('c:\WINDOWS\system32\cmd.exe /c START C:\xampp\htdocs\caliban\blobs.bat');

?>

これは私の blobs.bat です

php c:\xampp\htdocs\caliban\blobs.php

コマンド ラインを完全に非表示にするには

私はこのin.vbsファイルを作成し、これを

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

私のphpファイルは次のようになります

<?php
function close_connection(){
    ob_end_clean();
    header("Connection: close");
    ignore_user_abort(); // optional
    ob_start();
    $size = ob_get_length();
    header("Content-Length: $size");
    ob_end_flush();
    flush();
}
close_connection();
exec('c:\WINDOWS\system32\cmd.exe /c START C:\xampp\htdocs\caliban\in.vbs C:\xampp\htdocs\caliban\blobs.bat');

?>

これが他の誰かに役立つことを願っています。

参照

https://superuser.com/questions/62525/run-a-completly-hidden-batch-file

于 2013-06-10T09:31:00.720 に答える