1--TEST-- 2Test ~N operator : various numbers as strings 3--FILE-- 4<?php 5 6$strVals = array( 7 "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a", 8 "a5.9" 9); 10 11 12foreach ($strVals as $strVal) { 13 echo "--- testing: '$strVal' ---\n"; 14 var_dump(bin2hex(~$strVal)); 15} 16 17?> 18===DONE=== 19--EXPECT-- 20--- testing: '0' --- 21string(2) "cf" 22--- testing: '65' --- 23string(4) "c9ca" 24--- testing: '-44' --- 25string(6) "d2cbcb" 26--- testing: '1.2' --- 27string(6) "ced1cd" 28--- testing: '-7.7' --- 29string(8) "d2c8d1c8" 30--- testing: 'abc' --- 31string(6) "9e9d9c" 32--- testing: '123abc' --- 33string(12) "cecdcc9e9d9c" 34--- testing: '123e5' --- 35string(10) "cecdcc9aca" 36--- testing: '123e5xyz' --- 37string(16) "cecdcc9aca878685" 38--- testing: ' 123abc' --- 39string(14) "dfcecdcc9e9d9c" 40--- testing: '123 abc' --- 41string(14) "cecdccdf9e9d9c" 42--- testing: '123abc ' --- 43string(14) "cecdcc9e9d9cdf" 44--- testing: '3.4a' --- 45string(8) "ccd1cb9e" 46--- testing: 'a5.9' --- 47string(8) "9ecad1c6" 48===DONE=== 49