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