Thread: use of %s

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    Hi, new to PHP - have read half of the WROX book, but didn't find an explanation of the use of %s and %d as placeholders, as in the following code.

    printf("Untrusted PHP code: <i>%s</i>",
    htmlspecialchars($data));

    why this syntax, instead of

    printf("Untrusted PHP code: <i>htmlspecialchars($data)</i>",
    );

    Is there somewhere an explanation of using %s and %d as placeholders?

    Thanks for any help on this.

    ------------------
    John Newsom
    Director of Instructional Technology
    Bellevue Schools, Washington State
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    1
    Rep Power
    0
    The %s and %d are C string format specifiers. You can find them in any C or C++ book.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    60
    Rep Power
    15
    Go to www.php.net/manual and have fun searching for print, echo, printf, sprintf.

    Nelson

IMN logo majestic logo threadwatch logo seochat tools logo