Can PHP be used in Ruby?

D

darren kirby

quoth the James Britt:

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
 
D

David Vallner

--------------enig99FB32EA5A36488A0E97ED88
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

darren said:
quoth the James Britt:
=20
Not strictly no:
=20
irb(main):001:0> foo =3D `php foo.php`
=3D> "some value\n"
=20

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

David Vallner


--------------enig99FB32EA5A36488A0E97ED88
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFIAOUy6MhrS8astoRAvw+AJ4nlC2Y29cSGqSzCbY9MmznA8pnmwCeMesw
Lc+uM0aBMu4UmQOjz1rSGeE=
=mNS2
-----END PGP SIGNATURE-----

--------------enig99FB32EA5A36488A0E97ED88--
 
D

darren kirby

quoth the David Vallner:
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
 
J

Jeff Wood

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

quoth the David Vallner:

in/from potayto/potahto

Don't get me wrong, I am certainly not endorsing that sort of thing bu=
t =
 
C

Charles O Nutter

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,214
Messages
2,571,112
Members
47,704
Latest member
DavidSuita

Latest Threads

Top