note 99345 deleted from function.intval by cmb
| From: | cmb@php.net | Date: | Sun, 16 Feb 2020 13:47:13 +0000 |
| Subject: | note 99345 deleted from function.intval by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-214136@lists.php.net to get a copy of this message | ||
Note Submitter: jeremy at cfegames dot com
----
When retrieving numbers or integers from a MySQL DB, it's best to use intval(), or it will
continue to be a string.
<?php
while($row = mysql_fetch_array($check)
{
$_SESSION['id'] = inval($row['id']);
$user_id = intval($_SESSION['id']); // Not sure if you need to do it again, but
doesn't hurt.
}
is_int($_SESSION['id'])
is_int($user_id)
is_string($_SESSION['id'])
is_string($user_id)
// Output
true
true
false
false
?>