Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:14:09+00:00 2026-06-17T00:14:09+00:00

I found this code snippet for php: $sJavascript = <<<END_JAVASCRIPT var callback = arguments[arguments.length-1],

  • 0

I found this code snippet for php:

$sJavascript = <<<END_JAVASCRIPT

var callback = arguments[arguments.length-1], 
nIntervalId; 

function checkDone() {
  if( window.MY_STUFF_DONE ) {
    window.clearInterval(nIntervalId); // stop polling
    callback("done"); // return "done" to PHP code
  }
}

nIntervalId = window.setInterval( checkDone, 50 ); // start polling
END_JAVASCRIPT;

$sResult = $session->execute_async(array(
  'script' => $sJavascript,
  'args' => array(),
 ));

What is that ‘END_JAVASCRIPT’ string(?) and how and when should be use?
P.S. I tried to run this snippet but I get a parse error in PHP (‘unexpected $end’).

UPDATE:
The reason I was getting the parse error is that I indented the code (including the closing identifier ‘END_JAVASCRIPT’). The PHP heredoc documentation contains the following warning:

It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It’s also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:14:10+00:00Added an answer on June 17, 2026 at 12:14 am

    It’s heredoc syntax. Very useful for outputting large chunks of HTML, especially when you’re including PHP variable values, because they get interpreted as they do when using double-quotes, but with heredoc you don’t have to escape your double quotes.

    $str = "foo";
    echo <<< ARBITRARY_STRING
        <span class="blah">This is the $str var</span>
    ARBITRARY_STRING;
    

    Pay close attention to the closing ARBITRARY_STRING; line, in has to be on a line by itself and cannot have any whitespace at its start or after the semicolon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this code snippet to retrieve the title from a YouTube video and
I'm reading Programming Perl , and I found this code snippet: sub new {
found this little code snippet that seems to do what i want, but im
I found this great code snippet that works wonderfully during circumstances that change a
VS 2008 I have this code snippet I found on a VB website. But
I found this snippet of code I am having trouble trying to find a
I've found this snippet of code on the net. It sets up an NSMutableArray
I found this code on the internetz, it checks the current page url; function
I've found this code snippet: [self setValue:direction forKey:@currentDirection]; CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:@position];
I found this code snippet on a different post that I don't quite understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.