JavaScript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy Jackson

    JavaScript?

    I have a question, and I hope this one hasn't been asked too frequently; if
    so, I apologize in advance.

    I've heard over time that it isn't a good idea to intermingle JavaScript
    with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
    someone care to enlighten me as to why this might be the case?

    Thanks in advance for any responses.

    --
    Randy Jackson

  • Andy Hassall

    #2
    Re: JavaScript?

    On Sat, 10 Jul 2004 16:32:43 GMT, Randy Jackson
    <randyjackson@i gnorethispartfo urcolorexplosio n.com> wrote:
    [color=blue]
    >I have a question, and I hope this one hasn't been asked too frequently; if
    >so, I apologize in advance.
    >
    >I've heard over time that it isn't a good idea to intermingle JavaScript
    >with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
    >someone care to enlighten me as to why this might be the case?[/color]

    Well, you can't intermingle the two, since they won't run on the same machine
    anyway.

    What you can do is output Javascript source code from PHP for execution by the
    browser.

    What you shouldn't do is _rely_ on that Javascript to do anything, such as
    validation or filling in fields, since you don't have any control over the
    remote environment.

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Chung Leong

      #3
      Re: JavaScript?


      "Randy Jackson" <randyjackson@i gnorethispartfo urcolorexplosio n.com> wrote in
      message news:Xns952275F 6E703Frandyjack sonfourcolo@206 .141.193.32...[color=blue]
      > I have a question, and I hope this one hasn't been asked too frequently;[/color]
      if[color=blue]
      > so, I apologize in advance.
      >
      > I've heard over time that it isn't a good idea to intermingle JavaScript
      > with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
      > someone care to enlighten me as to why this might be the case?
      >
      > Thanks in advance for any responses.
      >
      > --
      > Randy Jackson
      > http://fourcolorexplosion.com[/color]

      It just gets really confusing, that's all. Slashes can get totally out of
      control when you have Javascript code sitting inside a PHP string. Here's an
      extreme case:

      echo "var re = new RegExp('\\\\\\\ \', 'g');";

      All the thing does is look for one backslash.


      Comment

      Working...