westman Posted November 28, 2013 Share Posted November 28, 2013 hi all, if I am passing information from php to javascript to print on the page using something like.. javascript:edit_item_link1(''.$item_name.''); what code of symbols will stop my javascript from working? Link to comment Share on other sites More sharing options...
davej Posted November 29, 2013 Share Posted November 29, 2013 You will have to put this in context. Link to comment Share on other sites More sharing options...
westman Posted December 2, 2013 Author Share Posted December 2, 2013 (edited) for example if you pass a line break through javascript, it does not work so is there any more code or symbols that will stop it working? Edited December 2, 2013 by westman Link to comment Share on other sites More sharing options...
justsomeguy Posted December 2, 2013 Share Posted December 2, 2013 If it contains the same quote that Javascript is using to enclose the string then that will break it, you need to escape those quotes also. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2013 Author Share Posted December 3, 2013 ok, so i can use in php $item_name = str_replace("'", "", $item_name);or$item_name = str_replace(""", "", $item_name); depending on my javascript format (thanks justsomeguy) how do I remove a line break from a string in php? Link to comment Share on other sites More sharing options...
Hadien Posted December 3, 2013 Share Posted December 3, 2013 $needles = array("'", ""","n","r");$replaces= array("'",'"',"", "");$item_name = str_replace($needles, $replaces, $item_name); don't simply use """. that is invalid code by itself in PHP . and those quotes might have been important, just escape them. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2013 Author Share Posted December 3, 2013 is a line break "n","r"? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now