You are here: Re: JS/PHP Integration « PHP Programming Language « IT news, forums, messages
Re: JS/PHP Integration

Posted by Peter Michaux on 04/27/07 14:40

On Apr 27, 7:35 am, ashore <3ash...@comcast.net> wrote:
> Say I'm using a snippet like
> $phpfoo = "a\nb\nc";
> var jsfoo = "<?php echo $phpfoo;?>";
>
> This errors out because JS sees the newline, and it needs to be
> escaped somehow. (In my real case, $phpfoo came from MySQL, and it's
> retrieved and displayed OK.)
>
> What do you folks use in this kind of situation? Thanks, all.

If the $phpfoo string in PHP contains a new line then this is
something you solve with PHP before you print it into the HTML page.
Turn the new line character into somthing that will print as "\n" into
the page if you want the JavaScript to see the new line.

Peter

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация