I have some values to save into postmeta and usermeta table. Before save, I already done this: $value = intval($value)
. I think this is enough. But I see some plugins still use filters on those numbers. I want to make sure that I can do with intval
and without safety filter.
Leave a Reply
You must be logged in to post a comment.
intval()
behaves sometimes a little bit counter-intuitive when then value has leading zeros or when it is a mathematic expression. The result should always be safe, but is not always what you might expect.A simple example:
will never return this value, because even 64 bit system cannot handle such a large number. You get
9223372036854775807
on a 64 bit system and2147483647
on 32 bit.But if you use:
$matches[0]
will return this number unchanged.So, it depends on the values you expect.