Hello to all

<?php $mars = time (); if ($kaka == 0) { $html = <<<HERE <div id="class"> <div id="dialod"> <center> <div id="ok_shareWidget"></div> <script> !function (d, id, did, st) { var js = d.createElement("script"); js.src = "<? echo $klass22; ?>"; js.onload = js.onreadystatechange = function () { if (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") { if (!this.executed) { this.executed = true; setTimeout(function () { OK.CONNECT.insertShareWidget(id,did,st); }, 0); } }}; d.documentElement.appendChild(js); }(document,"ok_shareWidget","http://site.ru/t3/s2.php?id=<? echo $create_id;?>","{width:125,height:50,st:'straight',sz:45,ck:1,nc:1}"); function listenForShare() { if (window.addEventListener) { window.addEventListener('message', onShare, false); } else { window.attachEvent('onmessage', onShare); } } function onShare(e) { var args = e.data.split("$"); if (args[0] == "ok_shared") { window.location="pe.php"; // Π’Ρ‹Π²ΠΎΠ΄ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€Π° Ρ„Ρ€Π΅ΠΉΠΌΠ° ΠΊΠ½ΠΎΠΏΠΊΠΈ - Π² случаС Π½Π΅ΡΠΊΠΎΠ»ΡŒΠΊΠΈΡ… ΠΊΠ½ΠΎΠΏΠΎΠΊ Π½Π° ΠΎΠ΄Π½ΠΎΠΉ страницС, ΠΏΠΎ Π½Π΅ΠΌΡƒ ΠΌΠΎΠΆΠ½ΠΎ ΠΎΠΏΡ€Π΅Π΄Π΅Π»ΠΈΡ‚ΡŒ какая ΠΈΠΌΠ΅Π½Π½ΠΎ Π±Ρ‹Π»Π° ΠΊΠ»ΠΈΠΊΠ½ΡƒΡ‚Π° if (alert) $( '#baner_grup' ).show(); $( '.classs' ).html('<meta http-equiv="refresh" content="0; url=http://site.ru/t/pre.php" />'); $( '#class' ).hide(); $( '.player' ).hide(); } } listenForShare(); </script> </div> </div> </div> </div> <div> HERE; } else { $x = 0; } 

what is the problem ?

    1 answer 1

    • After opening <<<HERE should be an end of the line immediately and no spaces!
    • End HERE; must be at the very beginning of the line without spaces before it! And no spaces after it! There should not be extra characters!
    • semicolon ; optional, but if it is, then between it and HERE also should not be extra characters

    And to consolidate the material quote from the documentation ( http://php.net/manual/ru/language.types.string.php#language.types.string.syntax.heredoc ):

    Attention

    It is very important to note that the line with the closing identifier must not contain other characters, except for the semicolon (;). This means that the identifier should not be indented and that there can be no spaces or tabs before or after the semicolon. It is also important to understand that the first character before the closing identifier must be a newline character defined in your operating system. For example, on UNIX systems, including Mac OS X, this is \ n. After the closing identifier, a new line should also begin immediately.

    If this rule is violated and the closing identifier is not "clean", it is assumed that there is no closing identifier and PHP will continue its search further. If in this case the correct closing identifier is not found, it will cause a parsing error with the line number at the end of the script.

    Also inside Heredoc do not write <? echo $create_id;?> <? echo $create_id;?> you just need to substitute the $create_id variable. Similarly with $klass22