PHP JavaScript Writing

Discussion in 'PHP' started by Pudge1, Aug 30, 2009.

  1. #1
    If I did something like this:

    <?
    $echo = "<script>document.write("test");</script>";

    imagefttext($echo);
    ?>

    Would it write the JavaScript output to the image?
    Obviously I wouldn't be using the document.write function I was just using it as an example. So is this possible?
     
    Pudge1, Aug 30, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Ofcourse it wouldn't, you just have a variable with that text in it.. It doesn't get interpreted by javascript at all.. I see no reason why you would want to do this anyway except if you're a code paster that doesn't want to port javascripts to php.
     
    premiumscripts, Aug 30, 2009 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    Like I said... I am only using this for an example. So is there anyway to get what JavaScript would output as a PHP variable.
     
    Pudge1, Aug 30, 2009 IP
  4. pneulameiro

    pneulameiro Peon

    Messages:
    440
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think it is not possible pudge1. Let's se why:

    with php you generates the html code.
    javascript is embeded in the html :)

    But you can pass javascript variables as html tags values atributes and get them as php variables after the page submit.
     
    pneulameiro, Aug 31, 2009 IP
  5. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You should tell us what the exact reason is you're trying to do this. It's not possible.

    There are serverside javascript implementations available, but not interchangeably via php.
     
    premiumscripts, Aug 31, 2009 IP
  6. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #6
    Well I am working around this so I no longer need help on it. Thanks to all who responded.
     
    Pudge1, Aug 31, 2009 IP