modulus_variationStr.phpt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. --TEST--
  2. Test % operator : various numbers as strings
  3. --FILE--
  4. <?php
  5. $strVals = array(
  6. "0","65","-44", "1.2", "-7.7", "abc", "123abc", "123e5", "123e5xyz", " 123abc", "123 abc", "123abc ", "3.4a",
  7. "a5.9"
  8. );
  9. error_reporting(E_ERROR);
  10. foreach ($strVals as $strVal) {
  11. foreach($strVals as $otherVal) {
  12. echo "--- testing: '$strVal' % '$otherVal' ---\n";
  13. var_dump($strVal%$otherVal);
  14. }
  15. }
  16. ?>
  17. ===DONE===
  18. --EXPECT--
  19. --- testing: '0' % '0' ---
  20. bool(false)
  21. --- testing: '0' % '65' ---
  22. int(0)
  23. --- testing: '0' % '-44' ---
  24. int(0)
  25. --- testing: '0' % '1.2' ---
  26. int(0)
  27. --- testing: '0' % '-7.7' ---
  28. int(0)
  29. --- testing: '0' % 'abc' ---
  30. bool(false)
  31. --- testing: '0' % '123abc' ---
  32. int(0)
  33. --- testing: '0' % '123e5' ---
  34. int(0)
  35. --- testing: '0' % '123e5xyz' ---
  36. int(0)
  37. --- testing: '0' % ' 123abc' ---
  38. int(0)
  39. --- testing: '0' % '123 abc' ---
  40. int(0)
  41. --- testing: '0' % '123abc ' ---
  42. int(0)
  43. --- testing: '0' % '3.4a' ---
  44. int(0)
  45. --- testing: '0' % 'a5.9' ---
  46. bool(false)
  47. --- testing: '65' % '0' ---
  48. bool(false)
  49. --- testing: '65' % '65' ---
  50. int(0)
  51. --- testing: '65' % '-44' ---
  52. int(21)
  53. --- testing: '65' % '1.2' ---
  54. int(0)
  55. --- testing: '65' % '-7.7' ---
  56. int(2)
  57. --- testing: '65' % 'abc' ---
  58. bool(false)
  59. --- testing: '65' % '123abc' ---
  60. int(65)
  61. --- testing: '65' % '123e5' ---
  62. int(65)
  63. --- testing: '65' % '123e5xyz' ---
  64. int(65)
  65. --- testing: '65' % ' 123abc' ---
  66. int(65)
  67. --- testing: '65' % '123 abc' ---
  68. int(65)
  69. --- testing: '65' % '123abc ' ---
  70. int(65)
  71. --- testing: '65' % '3.4a' ---
  72. int(2)
  73. --- testing: '65' % 'a5.9' ---
  74. bool(false)
  75. --- testing: '-44' % '0' ---
  76. bool(false)
  77. --- testing: '-44' % '65' ---
  78. int(-44)
  79. --- testing: '-44' % '-44' ---
  80. int(0)
  81. --- testing: '-44' % '1.2' ---
  82. int(0)
  83. --- testing: '-44' % '-7.7' ---
  84. int(-2)
  85. --- testing: '-44' % 'abc' ---
  86. bool(false)
  87. --- testing: '-44' % '123abc' ---
  88. int(-44)
  89. --- testing: '-44' % '123e5' ---
  90. int(-44)
  91. --- testing: '-44' % '123e5xyz' ---
  92. int(-44)
  93. --- testing: '-44' % ' 123abc' ---
  94. int(-44)
  95. --- testing: '-44' % '123 abc' ---
  96. int(-44)
  97. --- testing: '-44' % '123abc ' ---
  98. int(-44)
  99. --- testing: '-44' % '3.4a' ---
  100. int(-2)
  101. --- testing: '-44' % 'a5.9' ---
  102. bool(false)
  103. --- testing: '1.2' % '0' ---
  104. bool(false)
  105. --- testing: '1.2' % '65' ---
  106. int(1)
  107. --- testing: '1.2' % '-44' ---
  108. int(1)
  109. --- testing: '1.2' % '1.2' ---
  110. int(0)
  111. --- testing: '1.2' % '-7.7' ---
  112. int(1)
  113. --- testing: '1.2' % 'abc' ---
  114. bool(false)
  115. --- testing: '1.2' % '123abc' ---
  116. int(1)
  117. --- testing: '1.2' % '123e5' ---
  118. int(1)
  119. --- testing: '1.2' % '123e5xyz' ---
  120. int(1)
  121. --- testing: '1.2' % ' 123abc' ---
  122. int(1)
  123. --- testing: '1.2' % '123 abc' ---
  124. int(1)
  125. --- testing: '1.2' % '123abc ' ---
  126. int(1)
  127. --- testing: '1.2' % '3.4a' ---
  128. int(1)
  129. --- testing: '1.2' % 'a5.9' ---
  130. bool(false)
  131. --- testing: '-7.7' % '0' ---
  132. bool(false)
  133. --- testing: '-7.7' % '65' ---
  134. int(-7)
  135. --- testing: '-7.7' % '-44' ---
  136. int(-7)
  137. --- testing: '-7.7' % '1.2' ---
  138. int(0)
  139. --- testing: '-7.7' % '-7.7' ---
  140. int(0)
  141. --- testing: '-7.7' % 'abc' ---
  142. bool(false)
  143. --- testing: '-7.7' % '123abc' ---
  144. int(-7)
  145. --- testing: '-7.7' % '123e5' ---
  146. int(-7)
  147. --- testing: '-7.7' % '123e5xyz' ---
  148. int(-7)
  149. --- testing: '-7.7' % ' 123abc' ---
  150. int(-7)
  151. --- testing: '-7.7' % '123 abc' ---
  152. int(-7)
  153. --- testing: '-7.7' % '123abc ' ---
  154. int(-7)
  155. --- testing: '-7.7' % '3.4a' ---
  156. int(-1)
  157. --- testing: '-7.7' % 'a5.9' ---
  158. bool(false)
  159. --- testing: 'abc' % '0' ---
  160. bool(false)
  161. --- testing: 'abc' % '65' ---
  162. int(0)
  163. --- testing: 'abc' % '-44' ---
  164. int(0)
  165. --- testing: 'abc' % '1.2' ---
  166. int(0)
  167. --- testing: 'abc' % '-7.7' ---
  168. int(0)
  169. --- testing: 'abc' % 'abc' ---
  170. bool(false)
  171. --- testing: 'abc' % '123abc' ---
  172. int(0)
  173. --- testing: 'abc' % '123e5' ---
  174. int(0)
  175. --- testing: 'abc' % '123e5xyz' ---
  176. int(0)
  177. --- testing: 'abc' % ' 123abc' ---
  178. int(0)
  179. --- testing: 'abc' % '123 abc' ---
  180. int(0)
  181. --- testing: 'abc' % '123abc ' ---
  182. int(0)
  183. --- testing: 'abc' % '3.4a' ---
  184. int(0)
  185. --- testing: 'abc' % 'a5.9' ---
  186. bool(false)
  187. --- testing: '123abc' % '0' ---
  188. bool(false)
  189. --- testing: '123abc' % '65' ---
  190. int(58)
  191. --- testing: '123abc' % '-44' ---
  192. int(35)
  193. --- testing: '123abc' % '1.2' ---
  194. int(0)
  195. --- testing: '123abc' % '-7.7' ---
  196. int(4)
  197. --- testing: '123abc' % 'abc' ---
  198. bool(false)
  199. --- testing: '123abc' % '123abc' ---
  200. int(0)
  201. --- testing: '123abc' % '123e5' ---
  202. int(0)
  203. --- testing: '123abc' % '123e5xyz' ---
  204. int(0)
  205. --- testing: '123abc' % ' 123abc' ---
  206. int(0)
  207. --- testing: '123abc' % '123 abc' ---
  208. int(0)
  209. --- testing: '123abc' % '123abc ' ---
  210. int(0)
  211. --- testing: '123abc' % '3.4a' ---
  212. int(0)
  213. --- testing: '123abc' % 'a5.9' ---
  214. bool(false)
  215. --- testing: '123e5' % '0' ---
  216. bool(false)
  217. --- testing: '123e5' % '65' ---
  218. int(58)
  219. --- testing: '123e5' % '-44' ---
  220. int(35)
  221. --- testing: '123e5' % '1.2' ---
  222. int(0)
  223. --- testing: '123e5' % '-7.7' ---
  224. int(4)
  225. --- testing: '123e5' % 'abc' ---
  226. bool(false)
  227. --- testing: '123e5' % '123abc' ---
  228. int(0)
  229. --- testing: '123e5' % '123e5' ---
  230. int(0)
  231. --- testing: '123e5' % '123e5xyz' ---
  232. int(0)
  233. --- testing: '123e5' % ' 123abc' ---
  234. int(0)
  235. --- testing: '123e5' % '123 abc' ---
  236. int(0)
  237. --- testing: '123e5' % '123abc ' ---
  238. int(0)
  239. --- testing: '123e5' % '3.4a' ---
  240. int(0)
  241. --- testing: '123e5' % 'a5.9' ---
  242. bool(false)
  243. --- testing: '123e5xyz' % '0' ---
  244. bool(false)
  245. --- testing: '123e5xyz' % '65' ---
  246. int(58)
  247. --- testing: '123e5xyz' % '-44' ---
  248. int(35)
  249. --- testing: '123e5xyz' % '1.2' ---
  250. int(0)
  251. --- testing: '123e5xyz' % '-7.7' ---
  252. int(4)
  253. --- testing: '123e5xyz' % 'abc' ---
  254. bool(false)
  255. --- testing: '123e5xyz' % '123abc' ---
  256. int(0)
  257. --- testing: '123e5xyz' % '123e5' ---
  258. int(0)
  259. --- testing: '123e5xyz' % '123e5xyz' ---
  260. int(0)
  261. --- testing: '123e5xyz' % ' 123abc' ---
  262. int(0)
  263. --- testing: '123e5xyz' % '123 abc' ---
  264. int(0)
  265. --- testing: '123e5xyz' % '123abc ' ---
  266. int(0)
  267. --- testing: '123e5xyz' % '3.4a' ---
  268. int(0)
  269. --- testing: '123e5xyz' % 'a5.9' ---
  270. bool(false)
  271. --- testing: ' 123abc' % '0' ---
  272. bool(false)
  273. --- testing: ' 123abc' % '65' ---
  274. int(58)
  275. --- testing: ' 123abc' % '-44' ---
  276. int(35)
  277. --- testing: ' 123abc' % '1.2' ---
  278. int(0)
  279. --- testing: ' 123abc' % '-7.7' ---
  280. int(4)
  281. --- testing: ' 123abc' % 'abc' ---
  282. bool(false)
  283. --- testing: ' 123abc' % '123abc' ---
  284. int(0)
  285. --- testing: ' 123abc' % '123e5' ---
  286. int(0)
  287. --- testing: ' 123abc' % '123e5xyz' ---
  288. int(0)
  289. --- testing: ' 123abc' % ' 123abc' ---
  290. int(0)
  291. --- testing: ' 123abc' % '123 abc' ---
  292. int(0)
  293. --- testing: ' 123abc' % '123abc ' ---
  294. int(0)
  295. --- testing: ' 123abc' % '3.4a' ---
  296. int(0)
  297. --- testing: ' 123abc' % 'a5.9' ---
  298. bool(false)
  299. --- testing: '123 abc' % '0' ---
  300. bool(false)
  301. --- testing: '123 abc' % '65' ---
  302. int(58)
  303. --- testing: '123 abc' % '-44' ---
  304. int(35)
  305. --- testing: '123 abc' % '1.2' ---
  306. int(0)
  307. --- testing: '123 abc' % '-7.7' ---
  308. int(4)
  309. --- testing: '123 abc' % 'abc' ---
  310. bool(false)
  311. --- testing: '123 abc' % '123abc' ---
  312. int(0)
  313. --- testing: '123 abc' % '123e5' ---
  314. int(0)
  315. --- testing: '123 abc' % '123e5xyz' ---
  316. int(0)
  317. --- testing: '123 abc' % ' 123abc' ---
  318. int(0)
  319. --- testing: '123 abc' % '123 abc' ---
  320. int(0)
  321. --- testing: '123 abc' % '123abc ' ---
  322. int(0)
  323. --- testing: '123 abc' % '3.4a' ---
  324. int(0)
  325. --- testing: '123 abc' % 'a5.9' ---
  326. bool(false)
  327. --- testing: '123abc ' % '0' ---
  328. bool(false)
  329. --- testing: '123abc ' % '65' ---
  330. int(58)
  331. --- testing: '123abc ' % '-44' ---
  332. int(35)
  333. --- testing: '123abc ' % '1.2' ---
  334. int(0)
  335. --- testing: '123abc ' % '-7.7' ---
  336. int(4)
  337. --- testing: '123abc ' % 'abc' ---
  338. bool(false)
  339. --- testing: '123abc ' % '123abc' ---
  340. int(0)
  341. --- testing: '123abc ' % '123e5' ---
  342. int(0)
  343. --- testing: '123abc ' % '123e5xyz' ---
  344. int(0)
  345. --- testing: '123abc ' % ' 123abc' ---
  346. int(0)
  347. --- testing: '123abc ' % '123 abc' ---
  348. int(0)
  349. --- testing: '123abc ' % '123abc ' ---
  350. int(0)
  351. --- testing: '123abc ' % '3.4a' ---
  352. int(0)
  353. --- testing: '123abc ' % 'a5.9' ---
  354. bool(false)
  355. --- testing: '3.4a' % '0' ---
  356. bool(false)
  357. --- testing: '3.4a' % '65' ---
  358. int(3)
  359. --- testing: '3.4a' % '-44' ---
  360. int(3)
  361. --- testing: '3.4a' % '1.2' ---
  362. int(0)
  363. --- testing: '3.4a' % '-7.7' ---
  364. int(3)
  365. --- testing: '3.4a' % 'abc' ---
  366. bool(false)
  367. --- testing: '3.4a' % '123abc' ---
  368. int(3)
  369. --- testing: '3.4a' % '123e5' ---
  370. int(3)
  371. --- testing: '3.4a' % '123e5xyz' ---
  372. int(3)
  373. --- testing: '3.4a' % ' 123abc' ---
  374. int(3)
  375. --- testing: '3.4a' % '123 abc' ---
  376. int(3)
  377. --- testing: '3.4a' % '123abc ' ---
  378. int(3)
  379. --- testing: '3.4a' % '3.4a' ---
  380. int(0)
  381. --- testing: '3.4a' % 'a5.9' ---
  382. bool(false)
  383. --- testing: 'a5.9' % '0' ---
  384. bool(false)
  385. --- testing: 'a5.9' % '65' ---
  386. int(0)
  387. --- testing: 'a5.9' % '-44' ---
  388. int(0)
  389. --- testing: 'a5.9' % '1.2' ---
  390. int(0)
  391. --- testing: 'a5.9' % '-7.7' ---
  392. int(0)
  393. --- testing: 'a5.9' % 'abc' ---
  394. bool(false)
  395. --- testing: 'a5.9' % '123abc' ---
  396. int(0)
  397. --- testing: 'a5.9' % '123e5' ---
  398. int(0)
  399. --- testing: 'a5.9' % '123e5xyz' ---
  400. int(0)
  401. --- testing: 'a5.9' % ' 123abc' ---
  402. int(0)
  403. --- testing: 'a5.9' % '123 abc' ---
  404. int(0)
  405. --- testing: 'a5.9' % '123abc ' ---
  406. int(0)
  407. --- testing: 'a5.9' % '3.4a' ---
  408. int(0)
  409. --- testing: 'a5.9' % 'a5.9' ---
  410. bool(false)
  411. ===DONE===