Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post

    Can "//" be used inside a heredoc to comment out javascript?

    I use a heredoc to send javascript to the browser. I've been using 2 forward slashes inside the heredoc to comment out lines of javascript. It looked like it was working well for a while. The scripts seemed to work fine.

    I'm getting the javascript error "invalid regular expression flag v".

    I just learned a forward slash is the js regex delimiter. Are the 2 forward slashes I'm using (several sets of 2 forward slashes) in the heredoc causing the problem?

    I used 2 forward slashes to comment out a line of css (in style tags) in a heredoc. I got the firebug error "expecting declaration, but found "/" instead - moving on to next declaration".

    I removed the 2 forward slashes and that error disappeared.

    I still have the "invalid regular expression flag v" error, and the javascript doesn't work. Any suggestions?

    Thank you.
    Last edited by milesdriven; 10-13-2012 at 04:54 PM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,038
    Thanks
    23
    Thanked 589 Times in 588 Posts
    Any suggestions?
    Yeah if your having problems stop writing javascript in a php file. Write it directly to the html file or make a file to be included in the html. The include can be written in heredoc. Have you tried the nowdoc to see if there is a difference?
    Last edited by sunfighter; 10-13-2012 at 05:25 PM.

  • #3
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    The javascript has to be sent to the users browser after login, so php has to send it - unless there is another way of sending the js after login that I'm not aware of.

    Quote Originally Posted by sunfighter View Post
    make a file to be included in the html. The include can be written in heredoc.
    I'm not sure what you're saying. Does html have its own include function?


    Putting javascript in a php heredoc has been working well. I'm trying to figure out why the sudden "flag v" error. If there is a better way to send javascript to the browser after php login, I welcome all suggestions.

    The first thing I need to do is resolve the invalid regex flag v error.
    Last edited by milesdriven; 10-13-2012 at 05:27 PM.

  • #4
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hi - and thanks for your reply. I noticed were talking over each other on this thread. For now, the best thing for me to do is diagnose the flag error. As soon as I figure out what is causing that I'll be in a better position to determine what the best thing to do is. I study the nowdoc then too.

    Thank you

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Quote Originally Posted by milesdriven View Post
    For now, the best thing for me to do is diagnose the flag error. As soon as I figure out what is causing that I'll be in a better position to determine what the best thing to do is.
    Post the code that causes the error so we can help you figure it out. Just posting to let everyone know you are working on something isn't going to get you anywhere here.

  • #6
    Regular Coder
    Join Date
    Dec 2011
    Posts
    186
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Inigoesdr View Post
    Post the code that causes the error so we can help you figure it out. Just posting to let everyone know you are working on something isn't going to get you anywhere here.
    Yes, you're right.

    I isolated the area that was crashing. I tried to post, but it exceeded the 20k character limit. I eventually found the two lines that were causing the errors. Problem solved.

    Just in case it helps someone, here are those two lines. I removed the red dot in line 1. For line 2, the word highlighted in red in the first part of the line did not exist in the php array inside the push method. I added it as shown. These small items were enough to crash a huge script.
    Code:
    1) echo "id8AM_cc_exp_month. ="." [1];";
    
    2) for($st = 1; $st <= $days_in_month; $st++)
    {
    echo "id8AM_Click_To_Reset_Inserted_Into_Database.push($id8AM_Click_To_Reset_Inserted_Into_Database[$st]);\n";
    }
    Even though my script was too big to post, I appreciate everyone trying to help.
    Last edited by milesdriven; 10-15-2012 at 06:07 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •