About me | pbdR Tech | HPSC | Phyloclustering | R_note |

R_note -- The Exploration of Statistical Software R (統計軟體 R 深度歷險)
About R_note
Reference
MS Windows

Batch jobs
Function
Data/MySQL
Plot
String/Parse

Remark Lines
Classes/S3
S4 Methods
Batch more
Environment

Good Coding
Fast Loop
LAM/MPI/Rmpi
Recursion

PHP Call R
Basic C
R Call Fortran/C
R Call GSL
C Call R API
C Call R Objects
Standalone

Make Packages
C Pointer
Debug




Section: PHP Call R

This page privde three examples to use PHP call R including argument passing and graph display which are the basic functions used for WEB techniques. Each example provides the on-line result. The new version of R can also use Rscript to simplify the interface between R and PHP.




Example 1 -- PHP communicate with R

This page is for Linux only!!
  1. PHP code (ex_1.php)

        
    <?
    
      $cmd = "echo 'argv <- \"ex_1.r\"; source(argv)' | " .
             "/usr/bin/R --vanilla --slave";
      $ret = system($cmd);
      echo $ret;
    
    ?>
    

    This PHP file use shell command echo pipe arguments to R and accept the return from R and show it on web page.

  2. R script (ex_1.r)

         print(argv)

    This R script just print the arguments.

  3. Browse
    Put the "ex_1.php" and "ex_1.r" into the same directory and open web browser to link "ex_1.php".
    Click here to see the output return from R script "ex_1.r".

[ Go to top ]

Maintained: Wei-Chen Chen
E-Mail: wccsnow @ gmail.com
Last Revised: Dec 12 2016, 09:44 (CST Taipei, Taiwan)
Created: Oct 06 2003
free counters Best Resolution
IE6.0
1280x1024
small font