Hi,

I have a website on a server that apparently uses an older version of PHP.

If I have a statement like:

echo ("Hello - I am John's friend");

Both the apostophe and the hyphen will be displayed as question marks.

Any idea how to resolve this?
Thanks.

    jehaz wrote:

    Both the apostophe and the hyphen will be displayed as question marks.

    geez that must be old or somthing...

    run a script with [man]phpinfo[/man] in it to see what version of php you are running.. also try

    instead of
     echo ("Hello - I am Johns friend");
    try...
     echo 'Hello - I am Johns friend';
    or
     echo "Hello - I am Johns friend"
    or,
     echo '"Hello - I am Johns friend"';
    
    
      jehaz wrote:

      Hi,

      I have a website on a server that apparently uses an older version of PHP.

      If I have a statement like:

      echo ("Hello - I am John's friend");

      Both the apostophe and the hyphen will be displayed as question marks.

      Any idea how to resolve this?
      Thanks.

      Hi Jenaz. If you are getting a question mark, have you tried escaping the apostrophe's ?

      example :

       echo ('Hello - I am John\'s friend');  //notice the backslash and use of single quote
      

      also, is this data coming from a database or is in utf-8 format? If so, that is your problem and there are ways to correct this. If not, try the escaping and that shoudl also fix your problem. One method is to add this to your configuration file :

      CarpConf(’encodingout’,'UTF-8′);
      

        also, if you are copying/pasting out of something else, (ie like mircosoft word), you will see this happen. The apostrophe in microsoft word is not a standard apostrophe character, and so when pasted into the text box for php, it does not understand this character and converts it to a valid character (in this case, a question mark, indicating unknown character)

        make sure you are not pasting out of microsoft word, and also try manually typing it in. the older php versions do not matter as they properly escape quotes always and always have.

          Write a Reply...