Re:How not to protect against SQL injection (view source)
by robertduncan on Tuesday March 29, 2011 @04:41PM
(#2384353)
There may actually be a good reason for writing code like that. The time the content was generated by the server, perhaps?
[ Parent
| on HN ]
Re:How not to protect against SQL injection (view source)
by chc on Tuesday March 29, 2011 @04:53PM
(#2384422)
That wouldn't be a good reason for writing that code. Putting it in a function like that suggests that you expect the value to change. It's like the xkcd joke where a random() function is implemented to return 4, as determined by a fair dice roll. If you just wanted to store the time the page was generated, it would make more sense to use a constant — for example:
window.pageBirthday = <?php echo time(); ?>
Also, if they're on Stack Overflow asking why it doesn't correctly report the current time, that's a pretty good indicator that they're simply mistaken.