Is there a free script out there that converts javascript to php?

Discussion in 'PHP' started by offthedome, Jul 1, 2010.

  1. #1
    Is there a free script out there that converts javascript to php? I've tried googling it, but all that comes up is this "web code converter", and the free version doesn't do javascript to php.
     
    offthedome, Jul 1, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    Javascript can't be converted to php (the functionality can't but the syntax could), as the majority of javascripts functionality is browser side not server side, so they work differently.

    However you could parse the Javascript within php, using echo/print's.
     
    danx10, Jul 1, 2010 IP
  3. offthedome

    offthedome Active Member

    Messages:
    446
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    95
    #3
    I'm not asking to pass information from javascript to php. I know that in most cases that's nearly impossible.

    Given that javascript would do things client side and the other would do things server side, certainly there are many things that javascript and php can do equally well, like do simple operations on form input. I'm asking whether there is a script or program out there that I can enter my javascript into and it will output a php script that does the same thing.
     
    offthedome, Jul 1, 2010 IP
  4. Triggs

    Triggs Active Member

    Messages:
    84
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #4
    ...It's called echo.

    
    <?php
        echo 'setTimeout("alert(\"omg!\")")';
    ?>
    
    PHP:
     
    Triggs, Jul 1, 2010 IP
  5. contentboss

    contentboss Peon

    Messages:
    3,241
    Likes Received:
    54
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I've often wondered why there isn't a simple script to convert php to java. lose the '$' at the front of var names, make sure the vars are declared, string manipulation, flag up funcs that have no equivalent, that sort of thing.

    it would be useful.

    people might even pay for it.
     
    contentboss, Jul 1, 2010 IP
  6. Triggs

    Triggs Active Member

    Messages:
    84
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    93
    #6
    How would that be remotely useful?
    It would be counter productive, imo.
     
    Triggs, Jul 1, 2010 IP
  7. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #7
    a) Java.... and javascript are two very different things
    b) Why would you want to?

    At the end of the day, converting from a->b is merely going to lose efficiency since it relies on logic in the convertor, NOT the programmer.
     
    lukeg32, Jul 1, 2010 IP
  8. offthedome

    offthedome Active Member

    Messages:
    446
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    95
    #8
    Well, in the case of the javascript to php, i have a javascript that I know can be converted to php because i know the functions used exist in php. The problem for someone like me is, I'm not that good at php, so it would take a long time to figure them out and do it all manually.

    I know I may have to go that route anyway, but it just seems to me like given the syntax similarities between javascript and php, that such converters should exist. (
     
    offthedome, Jul 1, 2010 IP
  9. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #9
    With respect, a function in one language is an entirely different ballgame in another.... I see what you are saying, but having had to migrate an entire system from one to another, more than once, it opens up a whole lotta problems :/

    I get you; dont get me wrong, I feel your pain, but at the end of the day if you have the base code, porting from one language to another is usually quite interesting..... or maybe thats the programming geek inside of me :-(
     
    lukeg32, Jul 1, 2010 IP
  10. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #10
    it can be done manually
     
    gapz101, Jul 2, 2010 IP
  11. sanhit

    sanhit Peon

    Messages:
    318
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    how to do that and whats the use, I want to know...
     
    sanhit, Jul 17, 2010 IP
  12. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #12
    Kaizoku, Jul 17, 2010 IP
  13. caciocode

    caciocode Peon

    Messages:
    65
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    That's absolutely impossible.

    A script that converts one programming language to another?
     
    caciocode, Jul 17, 2010 IP