www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] apostrophes in php

  1. #1
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590

    resolved [RESOLVED] apostrophes in php

    Hi! This should be an obvious question with an easy answer. How do you echo an apostrophe without having a backslash behind it?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,144
    PHP Code:
    echo "'"
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Thanks, but that's not my question. When I execute echo code, say "Fred's", "Fred\'s" is echoed. How do I change it so it simply puts "Fred's"?
    Last edited by shane.carr; 06-01-2006 at 11:23 AM. Reason: wording

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,144
    The echo is not inserting the slash. The slash is (most likely) due to the data being output coming from a form input, and your installation of PHP (correctly) having "magic quotes" enabled. In any case, the stripslashes function will remove those slashes. To make the code portable (in case it's ever on a server where "magic quotes" are not enabled), you can do something like:
    PHP Code:
    $text $_POST['text'];
    if(
    get_magic_quotes_gpc())
    {
      
    $text stripslashes($text);
    }
    echo 
    $text
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    May 2006
    Location
    North of the South Pole
    Posts
    590
    Brilliant!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles