Jump to content

'<' . '?php' and '<' + 'script>


ignace

Recommended Posts

Anybody here that can tell me why you need to write:

 

 

file_put_contents('file.php', '<' . '?php ..');

 

 

document.write('<' + 'script>..</script>');

 

 

Instead of just writing <?php and <script ? It works without the concat, so why do I see it in some scripts? I tried Googling but it does not take symbols into account. Anyone of you guys know?

Link to comment
Share on other sites

For PHP you don't have to do that. For HTML I think only a "" has to be broken apart (because the JavaScript parsing comes after the browser has already determined the contents of the

Link to comment
Share on other sites

Well it works in both cases. At least when I tried it. HTML5 boilerplate has had it, I think. I have been wondering about this for years as to why you need to do that. Only recently did I have the courage to go and try to find an explanation on the internet. But nothing has yet turned up, implied knowledge it seems or many are just using it without knowing what it's for...

Link to comment
Share on other sites

The string '</' is not allowed in JavaScript, because it could be misinterpreted as the end of the script tag (SGML short tag notation). Do '<'+'/script>' instead.

Found that the other day researching something for somebody else. Can't take credit for it.

 

http://stackoverflow.com/questions/1014203/best-way-to-use-googles-hosted-jquery-but-fall-back-to-my-hosted-library-on-go

Underneath the accepted answer by boldewyn

Link to comment
Share on other sites

Perhaps syntax highlighting in the editor that was used to write the code messes up when it see's <?php (even when quoted as a string?) would be a crappy oversight on the SDK developers part but I can't really think of anything else?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.