Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.