SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question regarding coding practice in "PHP: Novice to Ninja" by Kevin Yank

    Hello,

    I am new to this forum and am going through Kevin Yank's "PHP and MySQL: Novice to Ninja". If there is a forum dedicated to that book, let me know and I will post there. Anyway, on page 182, I came across this code:

    PHP Code:
    ...
    <?php htmlout($joke['text']); ?>
    <input type="hidden" name="id" value="<?php echo $joke['id]; ?>">
    ...
    Why did the author use the htmlout() function to print out $joke['text'] but just used echo to print the $joke['id']? whats the difference? If I should post this in a different forum, let me know.

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Hi NewWebDesigner2 and welcome to SitePoint,

    If you keep reading from memory he talks about escaping the HTML that may be included in text which prevents XSS attacks on your site, the ID doesn't need this because it should always be an INT in your MySQL database.
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, thank you.


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
  •