User Tools

Site Tools


Sidebar



en:objects:app:external_apps:run_as_php

run_as_php

run_as_php($content,$path,$show=false,$params=""); - execute a php file on the computer where the human emulator is running.

The function accepts parameters as input:

  • $content – contents of the bat file
  • $path – path to the file
  • $show – whether to show the window with the result of execution
  • $params – parameters for passing a php file via argv[]

    After testing, the function returns the result of its work to the script :
  • true – completed successfully
  • false – failed

    PHP example:

    <?php $xhe_host = "127.0.0.1:7010";
     
    //connect the object to control the emulator, if not already connected
    if(!isset($path))
      $path = "../../../Templates/xweb_human_emulator.php";
    require($path);
     
    //Start
    echo "<hr> <font color = blue> app->".basename(__FILE__)."</font> <hr>";
     
    //PHP
    $php = "<?php $xhe_host =" 127.0.0.1:7010";
     ";
    $php = $php."if(count($"."argv)> 1) echo \u0022 arg1: $"." argv [1]  n  ";  n";
    $php = $php."if(count($"."argv)> 2) echo \u0022 arg2: $"." argv [2]  n  ";  n";
    $php = $php."echo('php is runnig');  n";
    $php = $php."sleep(15);  n";
    $php = $php."?>  n";
     
    //1
    echo "1.Run PHP in hidden state without parameters:";
    echo $app->run_as_php($php, "test \ 1.php", false, "")."<br>";
     
    //2
    echo "2.Run PHP visible without parameters:";
    echo $app->run_as_php($php, "test \ 1.php", true, "")."<br>";
     
    //3
    echo "3.Run PHP visible with parameters:";
    echo $app->run_as_php($php, "test \ 1.php", true, "1 2")."<br>";
     
    //end
    echo "<hr> <br>";
     
    //Quit
    $app->quit();
    ?>

    Python example:

    # Additional paths
    import sys
    sys.path.insert(0, '../../../Templates PY/')
     
    xhe_host = "127.0.0.1:7011"
    from xweb_human_emulator import *
     
    # Start
    echo("<hr> <font color = blue> app.xxxxxxxxx </font> <hr>")
     
    # PHP
    php = "<?php
    "
    php = php + "if count(argv)> 1) echo('arg1: argv [1]
    ')
    "
    php = php + "if count(argv)> 2) echo(\ u0022arg2: argv [2]
    \ u0022)
    "
    php = php + "echo('php is runnig'))
    "
    php = php + "sleep(15))
    "
    php = php + "
    "
     
    # 1
    echo("1.Run PHP in hidden state without parameters:")
    echo(app.run_as_php(php, "test \ 1.php", false, ""), "<br>")
     
    # 2
    echo("2.Run PHP visible without parameters:")
    echo(app.run_as_php(php, "test \ 1.php", true, ""), "<br>")
     
    # 3
    echo("3.Run PHP visible with parameters:")
    echo(app.run_as_php(php, "test \ 1.php", true, "1 2"), "<br>")
     
    # end
    echo("<hr> <br>")
     
    # Quit
    app.quit()

    C# example:

    #region using
     
    using System;
    using System.Diagnostics;
    using System.Collections.Generic;
    using System.Linq;
    using System.IO;
    using System.Text;
    using System.Threading;
     
    using XHE;
    using XHE.XHE_DOM;
    using XHE.XHE_System;
    using XHE.XHE_Window;
    using XHE.XHE_Web;
     
    #endregion
     
     class Program: XHEScript
     {
    static void Main(string [] args)
    {
    //init XHE
    server = "127.0.0.1:7010";
    InitXHE();
     
    //Start
    echo("<hr> <font color = blue> app.run_as_php </font> <hr>");
     
    //pkhp
    string php = "<?php  n";
    php = php + "echo \u0022 arg1: $"+" argv [1]  " n";
    php = php + "echo \u0022 arg2: $"+" argv [2]  ";  n";
    php = php + "sleep(5);  n";
    php = php + "?>  n";
     
    //1 step
    echo("1.Start in hidden state with parameters:");
    echo(app.run_as_php(php, "test \ 1.php", false, "2 3") + "<br>");
     
    //step 2
    echo("2.Start in visible state with parameters:");
    echo(app.run_as_php(php, "test \ 1.php", true, "2 5") + "<br>");
     
    //step 3
    echo("3.Start in visible state with parameters:");
    echo(app.run_as_php(php, "test \ 1.php", true, "3 4") + "<br>");
     
    //end
    echo("<hr> <br>");
     
    app.quit();
    }
    }

    Java Script example:

    //connect the object to control the emulator, if not already connected
    xhe_host = "127.0.0.1:7010";
    echo = require("../../../Templates JS/xweb_human_emulator.js");
     
    //Start
    echo("<hr> <font color = blue> app.run_as_php </font> <hr>");
     
    //pkhp
    php = " n";
    php + = "echo \u0022 arg1: $argv [1]  ";  n";
    php + = "echo \u0022 arg2: $argv [2]  ";  n";
    php + = "sleep(5);  n";
    php + = " n";
     
    //1 step
    echo("1.Start in hidden state without parameters:");
    echo(app.run_as_php(php, "test \ 1.php", false) + "<br>");
     
    //step 2
    echo("2.Start in visible state with no parameters:");
    echo(app.run_as_php(php, "test \ 1.php", true) + "<br>");
     
    //step 3
    echo("3.Start in visible state with parameters:");
    echo(app.run_as_php(php, "test \ 1.php", true, "1 2") + "<br>");
     
    //end
    echo("<hr> <br>");
     
    //Quit
    app.quit();
  • en/objects/app/external_apps/run_as_php.txt · Last modified: 2026/08/05 22:31 (external edit)