Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Feb 2003
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile special character like " ' !

    hello there,

    How do I handle special characters like " ' !

    how to I insert and retrieve and quote this in my forum? or form field?

    thanks for any comment

  • #2
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I really dont understand what you mean.

    Do you want to put quotes in or do you want to remove the backslash \ that gets put in front of some quotes?

    Could you give a bit more info please?

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I just read it again, And I think I may know:

    If you want to put quotes into a string, do this...

    PHP Code:

    $string 
    "Hello I'm Matthew"// Single quotes ok, because they are within double quotes.

    $string "Hello, I'm \"Matthew\""// Double quotes need to have a \\ before them in strings with double quotes.

    $string 'Hello, I\\\'m Matthew'// Single quotes need to be backslashed because they are within single quotes.

    $string 'Hello I\\\'m "Matthew"'// Double quotes ok, beacuse they are within single quotes. 
    Does this help?

    Edit:
    I just noticed that VB Strips slashes ( like the stripslashes given below ) when they are behind certain chars. Some of single quotes should have backslashes behind them.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What if he wants to remove those annoying back slashes in front of each quote when printing a string?

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Iowa / Notre Dame
    Posts
    538
    Thanks
    0
    Thanked 0 Times in 0 Posts
    stripslashes($string);

    That will remove the "magic quotes" that php puts into strings. I believe you can also turn magic quotes off completley, though I feel better with myself just using stripslashes, I mean, I don't like messing with the config too much .

    This site has more info: http://www.php.net/manual/en/function.stripslashes.php
    My Site {Mike's Adventures}

    Yikes, forums are almost too much fun.

  • #6
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was thinking stripslashes, but It didnt sound like he wanted that?

    I should have put it any way.

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    Iowa / Notre Dame
    Posts
    538
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Don't worry 'bout it missing-score. I think he/she did want the info you gave, I was just answering ConfusedOfLife's question.
    My Site {Mike's Adventures}

    Yikes, forums are almost too much fun.

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •