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