[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Can PHP be used in Ruby?

terrywu1526

10/1/2006 4:37:00 PM

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

10 Answers

James Britt

10/1/2006 4:49:00 PM

0

terrywu1526@gmail.com wrote:
> Can I run some PHP code in Ruby, and access the variables?

No.

darren kirby

10/1/2006 5:52:00 PM

0

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"

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
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

David Vallner

10/1/2006 6:06:00 PM

0

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

darren kirby

10/1/2006 9:22:00 PM

0

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
--
darren kirby :: Part of the problem since 1976 :: http://badco...
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Jeff Wood

10/1/2006 10:06:00 PM

0

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 =3D `php foo.php`
>> > =3D> "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 bu=
t =

> it is
> a way to get a php variable's value into Ruby...
>
> -d



Charles O Nutter

10/2/2006 4:44:00 AM

0

On 10/1/06, terrywu1526@gmail.com <terrywu1526@gmail.com> 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.

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

Jim G.

11/15/2011 9:57:00 PM

0

cloud dreamer sent the following on Tue, 15 Nov 2011 15:37:08 -0330:
> On 15/11/2011 2:43 PM, number6 wrote:
> >
> > You don't have to understand the science to make something
> > scientifically logical ...
> > People don't have to understand gravity to know if you throw a ball up
> > in the air and it doesn't come down ... something is wrong ...
>
> Seriously, what is so illogical here that the vast majority of the
> audience would even notice??? We're talking about people so limited in
> their scientific know-how, they think that climate change is a hoax
> because it still snows.

It's a good thing you're not the condescending type, or anything.

> > Your premise that because the eight o'clock hour has children
> > watching, writers can get away with lazy science since it only has to
> > entertain mindlessly is nonsense ...
>
> No. I'm saying if they make it too complicated, you'll tune out the
> audience, including the adults.

For most of us English speakers, "realistic" and "complicated" are not
synonymous.

> The vast majority of the audience
> doesn't give a shit where the fuel came for the fire. They don't care
> that the kid that got killed by the dino thought his friend was inside
> and drunk. All that matters to them is the dinos were repelled and the
> kid got eaten by a dinosaur trapped in the building.

Are you polling this vast majority of people, or something?

>Do you honestly
> think having them fully explain where the fuel came from would make it
> better show??

It certainly wouldn't have to make it worse.

--
Jim G. | Waukesha, WI
NoCLoDS Founding Member (No Cop, Lawyer or Doctor Shows)

Jim G.

11/15/2011 9:57:00 PM

0

number6 sent the following on Tue, 15 Nov 2011 10:13:47 -0800 (PST):
> You don't have to understand the science to make something
> scientifically logical ...
> People don't have to understand gravity to know if you throw a ball up
> in the air and it doesn't come down ... something is wrong ...
>
> Your premise that because the eight o'clock hour has children
> watching, writers can get away with lazy science since it only has to
> entertain mindlessly is nonsense ...
>
> Hey Joe you have the sun setting in the west ... Ah screw it ... only
> kids watching ...

What s/he said. (But you're gonna catch grief over that "west" hiccup.)

--
Jim G. | Waukesha, WI
NoCLoDS Founding Member (No Cop, Lawyer or Doctor Shows)

Ron Capik

11/15/2011 10:13:00 PM

0

On 11/15/2011 4:52 PM, Obveeus wrote:
> "Ken from Chicago"<kwicker1b_nospam@comcast.net> wrote:
>
>> True enough, except they've *already* explained it was a parallel
>> timeline.
>
> They said they didn't find the beacon, so it was a parallel timeline. Are
> you honestly telling me that there is no other reason they might not have
> found the beacon...perhaps because it will be a plot point later on?
>
>> They gain nothing from backtracking on that. The audience that would
>> understand would be ticked off and the amount of paradoxes the show was
>> introducing.
>
> On;ly if that super intelligent audience foolishly believes that killing a
> butterfly 85 million years earlier *has* to affect humans in 2159. This
> colony could realistically thrive for hundreds of thousands of years, get
> completely wiped out by an asteroid, and leave no remnant or change upon the
> future at all.
>
>> The rest of the audience wouldn't understand and thus not care about such
>> a "shocking" turn of events.
>
> One of the big problems Sci-fi has is all the viewers that are so smart they
> think that the show has to be written a certain way or it is *stupid*.
> Witness the number of posters that claimed meteors do not cause EMP events
> and called the show stupid for portraying it otherwise. Those same people
> will line up to claim that there must be paradoxes if this turns out to be
> the same universe.
>
>
For what [little] it's worth, I said a meteor could not cause an E1 or E2
type EMP event. A meteor may cause a slower E3 type event, one not
known to wipe out small electronic devices. I believe there is real science
to back that up.

On the other hand, the [potential] paradoxes of time travel are all science
fiction speculation.
[YMMV]

Later...
==

tenworld

11/15/2011 10:38:00 PM

0

On Nov 15, 2:13 pm, Ron Capik <r.ca...@verizon.net> wrote:
> On 11/15/2011 4:52 PM, Obveeus wrote:
>
>
>
> > "Ken from Chicago"<kwicker1b_nos...@comcast.net>  wrote:
>
> >> True enough, except they've *already* explained it was a parallel
> >> timeline.
>
> > They said they didn't find the beacon, so it was a parallel timeline.  Are
> > you honestly telling me that there is no other reason they might not have
> > found the beacon...perhaps because it will be a plot point later on?
>
> >> They gain nothing from backtracking on that. The audience that would
> >> understand would be ticked off and the amount of paradoxes the show was
> >> introducing.
>
> > On;ly if that super intelligent audience foolishly believes that killing a
> > butterfly 85 million years earlier *has* to affect humans in 2159.  This
> > colony could realistically thrive for hundreds of thousands of years, get
> > completely wiped out by an asteroid, and leave no remnant or change upon the
> > future at all.
>
> >> The rest of the audience wouldn't understand and thus not care about such
> >> a "shocking" turn of events.
>
> > One of the big problems Sci-fi has is all the viewers that are so smart they
> > think that the show has to be written a certain way or it is *stupid*.
> > Witness the number of posters that claimed meteors do not cause EMP events
> > and called the show stupid for portraying it otherwise.  Those same people
> > will line up to claim that there must be paradoxes if this turns out to be
> > the same universe.
>
> For what [little] it's worth, I said a meteor could not cause an E1 or E2
> type EMP event. A meteor may cause a slower E3 type event, one not
> known to wipe out small electronic devices. I believe there is real science
> to back that up.
>
> On the other hand, the [potential] paradoxes of time travel are all science
> fiction speculation.

I think we need to come up with a scale for science fiction
credibility, call it the ASIMOV Number. Where 1 is totally believable
and has real science and 10 no way.

Some examples:

10 - Harry Potters wand (OK maybe thats not SF but its also not
believable for a second)
9 - whales develop technology and build spaceships (how do you do
metallurgy without fire?)
8 - diving into a black hole and coming out in another galaxy
7 - transporters (great gimmick for writers but really do you think
you can live thru it?)
6 - worm holes (same as transported but has some theory)
5 - warp drive (dilithium as material partly in 4th dimension)
4 - point to point jumps (folded universe has more mathematical basis
than accelerating past light speed)
3 - EMP pulse from meteor (pulse is known possible, Terra Nova affect
isnt)
2- existence of aliens with spaceships (see 4&5, but given the number
of planets now known to exist this is an increasing probability
1- cloning humans (despite fakes, this technology is close)