Can PHP be used in Ruby?

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

[email protected] wrote:

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

No.

quoth the James B.:

[email protected] 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”

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

quoth the David V.:

=> “some value\n”

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

David V.

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

darren kirby wrote:

quoth the James B.:

[email protected] 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 V.

On 10/1/06, [email protected] [email protected] wrote:

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

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.

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