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
https://forums.phpfreaks.com/topic/264649--/
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
https://forums.phpfreaks.com/topic/264649--/#findComment-1356350
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
https://forums.phpfreaks.com/topic/264649--/#findComment-1356409
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
https://forums.phpfreaks.com/topic/264649--/#findComment-1356432
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.