Jump to content

wierd characters


Shadowing

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/266856-wierd-characters/
Share on other sites

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>';

Link to comment
https://forums.phpfreaks.com/topic/266856-wierd-characters/#findComment-1368092
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.