Reputation: 83
I have tried creating a script to prevent spamming. Every 30 seconds will allow you to post again. I am using time()
to use it (php unix time) and then uploading it to the user's profile. So lastpost
=time(); (basically)
$ayy = $user['lastpost'];
die($ayy);
That returns the user last posted. For this example, the last time the user has posted was 14423658. When I apply simple math to it, such as
die($ayy - 3);
it will output nothing. If I convert the value to a integer, doing
$ayy = intval($user['lastpost']);
The $ayy
value will just become null (blank). How I know this is when I perform
die($ayy);
It outputs nothing. If I do
$ayy = intval($user['lastpost']);
die($ayy - 1);
or
$ayy = $user['lastpost'];
die(intval($ayy - 1));
They all output nothing. You'd expect something like this to be very simple, but I have spent days pondering this, and it is really frustrating.
If you do contribute, thanks.
EDIT
When var_dump is applied to $ayy, this is what it outputs:
string(14423658)
when intval
is applied to $ayy
, this is also what it outputs: int(14423658)
. It was working the whole time (with intval
) but it didn't output anything. Problem Solved, but why is it outputting blank?
Upvotes: 0
Views: 32
Reputation: 7504
According to manual http://php.net/manual/en/function.exit.php (exit is equivalent for die):
if status is integer it's not printed.
If you want to print it with die(I don't know why) do like this die((string)$ayy).
Upvotes: 2