Can PHP be used in Ruby?

Can I run some PHP code in Ruby, and access the variables?

terrywu1526@gmail.com wrote:

Can I run some PHP code in Ruby, and access the variables?

No.

Not really with stock Ruby. However along with JRuby there is a
project to run PHP on the JVM. A design goal for all the languages now
being supported is that there should be as little barrier to calling
from one to another as possible. It's reasonable to think that as
JRuby and the PHP implementation (Quercus) mature, the boundary
between the two will lessen. Indeed, we've already discussed with some
of the Javascript-oriented folks at Sun how to make Javascript and
Ruby work well together in the JVM. Interoperability will happen, so
you may get what you're looking for in the near future.

···

On 10/1/06, terrywu1526@gmail.com <terrywu1526@gmail.com> wrote:

Can I run some PHP code in Ruby, and access the variables?

--
Contribute to RubySpec! @ Welcome to headius.com
Charles Oliver Nutter @ headius.blogspot.com
Ruby User @ ruby.mn

quoth the James Britt:

> Can I run some PHP code in Ruby, and access the variables?

No.

Not strictly no:

irb(main):001:0> foo = `php foo.php`
=> "some value\n"

where foo.php is:

<?php
$foo = "some value";
echo $foo;
?>

Though the real question is why you would want to do something as ridiculous
as this?

OP: Explain what you are trying to accomplish and someone here can probably
give you some good advice...

-d

···

terrywu1526@gmail.com wrote:

--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

darren kirby wrote:

quoth the James Britt:

Can I run some PHP code in Ruby, and access the variables?

No.

Not strictly no:

irb(main):001:0> foo = `php foo.php`
=> "some value\n"

That's not quite running PHP code in ruby, is it?

David Vallner

···

terrywu1526@gmail.com wrote:

quoth the David Vallner:

darren kirby wrote:
> quoth the James Britt:
>>> Can I run some PHP code in Ruby, and access the variables?
>>
>> No.
>
> Not strictly no:
>
> irb(main):001:0> foo = `php foo.php`
> => "some value\n"

That's not quite running PHP code in ruby, is it?

David Vallner

in/from potayto/potahto

Don't get me wrong, I am certainly not endorsing that sort of thing but it is
a way to get a php variable's value into Ruby...

-d

···

>> terrywu1526@gmail.com wrote:

--
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Actually, you can use pretty much anything you want ...

I tend to start up an external process running whatever ( perl, python, php, java, C++, whatever ) ... and have it run a XMLRPC engine ...

Then I just send code that means something to that engine ...

So, with everything but C++ you can just do evals on the xmlrpc side ... ( in java I recommend beanshell ) ... let it do what it needs to do ... and return a string or integer or whatever ... ( usually if I need a complex data structure I pass YAML back and forth since there are YAML engines for most any programming language you could want to use ) ...

Anyways ... that's how I go about it ... it definately lets you use Ruby as glue or as your controller ...

... hope that helps.

jd

···

On Sun, 01 Oct 2006 14:22:01 -0700, darren kirby <bulliver@badcomputer.org> wrote:

quoth the David Vallner:

darren kirby wrote:
> quoth the James Britt:
>> terrywu1526@gmail.com wrote:
>>> Can I run some PHP code in Ruby, and access the variables?
>>
>> No.
>
> Not strictly no:
>
> irb(main):001:0> foo = `php foo.php`
> => "some value\n"

That's not quite running PHP code in ruby, is it?

David Vallner

in/from potayto/potahto

Don't get me wrong, I am certainly not endorsing that sort of thing but it is
a way to get a php variable's value into Ruby...

-d