in my javascript
javascrit: alert("Hello, <?php echo($name)?>")
If someone put in the name like with the quotes, such as "Ford Company", instead of Mr. Ford.
Then my javascript will be with error.
Because it will be
alert("Hello, "Ford Company"");
Instead of using str_replace(""", "\"", str_replace("'", "\'",$name)) to escape the " and ', is there better way to handle it?
Will just escape the ' and " will prevent other problems in my javscript such as in the name they put in with other strange characters?
Is there a function like htmlentities to solve all the html tags issues, is there a function let me some my problem, embedding the php in the javascript?
thanks.