note 118903 added to language.types.integer

From: Date: Thu, 25 Feb 2016 08:26:30 +0000
Subject: note 118903 added to language.types.integer
Groups: php.notes 
Request: Send a blank email to php-notes+get-205039@lists.php.net to get a copy of this message
<?php $ipArr = explode('.', $ipString); $ipVal = ($ipArr[0] << 24) + ($ipArr[1] << 16) + ($ipArr[2] << 8) + $ipArr[3] ; ?> 1. the priority of bit op is lower than '+',so there should be brackets. 2. there is no unsighed int in PHP, if you use 32 bit version,the code above will get negative result when the first position of IP string greater than 127. 3. what the code actually do is calculate the integer value of transformed 32 binary bit from IP string. ---- Server IP: 72.52.91.14 Probable Submitter: 218.108.29.107 ---- Manual Page -- http://php.net/manual/en/language.types.integer.php Edit -- https://master.php.net/note/edit/118903 Del: integrated -- https://master.php.net/note/delete/118903/integrated Del: useless -- https://master.php.net/note/delete/118903/useless Del: bad code -- https://master.php.net/note/delete/118903/bad+code Del: spam -- https://master.php.net/note/delete/118903/spam Del: non-english -- https://master.php.net/note/delete/118903/non-english Del: in docs -- https://master.php.net/note/delete/118903/in+docs Del: other reasons-- https://master.php.net/note/delete/118903 Reject -- https://master.php.net/note/reject/118903 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#205039) next »