Shadowing Posted August 9, 2012 Share Posted August 9, 2012 I had a problem come up where i have users using this wierd character when typing ? When this character is used at the end of a line it makes my script fail $return = "?"; If i echo it works but if i try to insert it into an array for ajax it returns NULL the variable in the array ends up NULL echo json_encode(array("display" => $return)); Anyone know what i need to do to filter this? i wraped htmlspecialchars around it and it didnt work EDIT: the forum doesnt allow me to type in the wierd character so it shows as a question mark instead Quote Link to comment https://forums.phpfreaks.com/topic/266856-wierd-characters/ Share on other sites More sharing options...
jazzman1 Posted August 9, 2012 Share Posted August 9, 2012 I think, it is good idea to post out more of your code. This one works for me: $arr = array( 'name'=>'jazzman', 'time'=>'2PM', 'phone' => '654-234-1129', 'spacial1'=>'?', 'spacial2' =>'\?' ); ?> //jquery get method <script type="text/javascript"> $(document).ready(function(){ $.get('code.php',<?php echo json_encode($arr);?>,function(data){ console.log(data); }) }) </script> code.php echo '<pre>'.print_r($_GET, true).'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/266856-wierd-characters/#findComment-1368092 Share on other sites More sharing options...
Shadowing Posted August 10, 2012 Author Share Posted August 10, 2012 thanks for the responce jazzman I think i got it figured out apparently i need to be using a header using header('Content-Type: text/html; charset=utf-8'); Quote Link to comment https://forums.phpfreaks.com/topic/266856-wierd-characters/#findComment-1368307 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.