note 116498 added to function.ftok
| From: | seelts at gmail dot com | Date: | Tue, 13 Jan 2015 12:17:10 +0000 |
| Subject: | note 116498 added to function.ftok | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201419@lists.php.net to get a copy of this message | ||
abk@avatartechnology.com has copied the code of daniele_dll@yahoo.it
But it is not correct.
The right version is here:
<?php
function ftok ($filePath, $projectId) {
$fileStats = stat($filePath);
if (!$fileStats) {
return -1;
}
return sprintf('%u',
($fileStats['ino'] & 0xffff) | (($fileStats['dev'] & 0xff) <<
16) | ((ord($projectId) & 0xff) << 24)
);
}
?>
The difference is that $projectId string should be used as ASCII value via ord() function. Otherwise
it will be interpreted as 0.
----
Server IP: 72.52.91.14
Probable Submitter: 213.108.168.158
----
Manual Page -- http://php.net/manual/en/function.ftok.php
Edit -- https://master.php.net/note/edit/116498
Del: integrated -- https://master.php.net/note/delete/116498/integrated
Del: useless -- https://master.php.net/note/delete/116498/useless
Del: bad code -- https://master.php.net/note/delete/116498/bad+code
Del: spam -- https://master.php.net/note/delete/116498/spam
Del: non-english -- https://master.php.net/note/delete/116498/non-english
Del: in docs -- https://master.php.net/note/delete/116498/in+docs
Del: other reasons-- https://master.php.net/note/delete/116498
Reject -- https://master.php.net/note/reject/116498
Search -- https://master.php.net/manage/user-notes.php