Creating a PHP script

 

In addition to using ILE RPG and RPG Open Access on the server side, Profound UI also allows you to use PHP with Rich Display Files.

To implement an equivalent Hello World application with PHP, follow these steps:

  • Save the Rich Display File to the IFS File System (the default location is shown below):

        

  • Create the helloworld.php script below.  You can place it in the following location on the IFS: /www/<YOUR SERVER INSTANCE NAME>/htdocs/profoundui. 

<?php header("Content-Type: application/json"); if (isset($_POST['btnExit']) && $_POST['btnExit'] == '1') { return; } $view = '/profoundui/userdata/dspf/HelloWorld.json'; $output = array('view' => $view, 'screen' => 'HELLO'); echo json_encode($output); ?>

 

The code explained:

  • The header directive is used to make sure the server and browser handles the output correctly.

  • User feedback is passed back as post data. Thus, $_POST['btnExit'] is used to check whether the Exit button was pressed (Note that the $_POST array is case sensitive). btnExit is the response variable assigned to the Exit button.  If '1' is posted, the user clicked the Exit button.

  • The output is an associative array, encoded in json.  The following output items are important:

    • 'view' - path to the view, or Rich Display File

    • 'screen' - each view may have multiple screens or formats; therefore, a 'screen' item must be specified.  In this example, the 'screen' item could have been omitted because there is only one screen in this view.  When the 'screen' item is omitted, the first view is used.

    • 'data' - this item is used to pass the dynamic data used to fill the screen.  In this example, there is no data, and therefore the 'data' item is not used.