SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about PHP syntax

    I'm converting some ASP into PHP and in one instance of the ASP this is used chr().

    This is exactly how it is used:

    body = body + "Comments" + chr(13) + Request.Form("Comments") & chr(13)

    I suppose chr(13) means 13 spaces. How would one code that in PHP? Does it have something similar?

  2. #2
    SitePoint Guru enygmadae's Avatar
    Join Date
    Sep 2002
    Location
    Dallas, Tx.
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    chr() is used to output a character in PHP, like chr(13) would out put the ACSII character 13 (a newline i think).

    it does that in PHP as well i guess...
    PHP News, Views and Community: http://www.phpdeveloper.org

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    13 is the ASCII character code for the "carriage return" CR.

    In PHP this you can use "\r".

    Note the string must be in double quotes so that the php engine will parse the string and replace the escaped r with the CR character.

    "\r" -> carriage return
    "\t" -> tab
    "\n" -> new line feed
    PHP Code:
    $body $body "Comments\r" $_POST["Comments"] . "\r"
    However, note that PHP does also have the chr() function so you don't really need to convert that part of the code.
    http://www.php.net/chr


    http://www.haneng.com/FunctionSearch.asp?s=Chr
    http://www.asciitable.com/

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    lalal
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and just in case anyone is interested, to do the 13 spaces thing you could use str_pad()


Bookmarks

Posting Permissions

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