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