Incorporating PHP in RUBY

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SSasidaran
    New Member
    • Dec 2010
    • 4

    Incorporating PHP in RUBY

    Hi All,

    I want to use PHP function in ruby code. I want to pass ruby variables to php function. And can anyone say how to run call a php function in ruby model.

    Ruby Model
    Code:
    class test < ActiveRecord::Base
    
    def sample 
     a1 = "username"
     a2 = "value"
     
    // here i need to use php funtion that will be using the ruby variable
    
    end
    end
    
    PHP File
    <?php
    function sas($username , $value)
    {
    echo "Test PHP Program";
    echo $username;
    echo $value;
    }
    echo "OUT";
    ?>
    Does any body has idea about Serialize in ruby so that i can store the variables and i can use stored variables and i can unserialize in PHP.

    Please help me. Thanks in advance.
    Last edited by numberwhun; Jan 17 '11, 09:11 PM. Reason: Please Use Code Tags!
  • SSasidaran
    New Member
    • Dec 2010
    • 4

    #2
    passing the value as command line php argument in ruby soved the problem

    Code:
    %x= [/usr/local/apache/php php/frist.php choclates,snacks]
    and in php this can be read by
    Code:
    print $argv[1];
    print $argv[2];
    Last edited by numberwhun; Jan 17 '11, 09:11 PM. Reason: Please Use Code Tags!

    Comment

    Working...