By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

JavaScript?

P: n/a
I have a question, and I hope this one hasn't been asked too frequently; if
so, I apologize in advance.

I've heard over time that it isn't a good idea to intermingle JavaScript
with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
someone care to enlighten me as to why this might be the case?

Thanks in advance for any responses.

--
Randy Jackson
http://fourcolorexplosion.com
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Sat, 10 Jul 2004 16:32:43 GMT, Randy Jackson
<ra**********@ignorethispartfourcolorexplosion.com > wrote:
I have a question, and I hope this one hasn't been asked too frequently; if
so, I apologize in advance.

I've heard over time that it isn't a good idea to intermingle JavaScript
with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
someone care to enlighten me as to why this might be the case?


Well, you can't intermingle the two, since they won't run on the same machine
anyway.

What you can do is output Javascript source code from PHP for execution by the
browser.

What you shouldn't do is _rely_ on that Javascript to do anything, such as
validation or filling in fields, since you don't have any control over the
remote environment.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

P: n/a

"Randy Jackson" <ra**********@ignorethispartfourcolorexplosion.com > wrote in
message news:Xn**********************************@206.141. 193.32...
I have a question, and I hope this one hasn't been asked too frequently; if so, I apologize in advance.

I've heard over time that it isn't a good idea to intermingle JavaScript
with PHP code. Maybe that's a fallacy, and maybe not, but if so, would
someone care to enlighten me as to why this might be the case?

Thanks in advance for any responses.

--
Randy Jackson
http://fourcolorexplosion.com


It just gets really confusing, that's all. Slashes can get totally out of
control when you have Javascript code sitting inside a PHP string. Here's an
extreme case:

echo "var re = new RegExp('\\\\\\\\', 'g');";

All the thing does is look for one backslash.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.