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(0)
58--- testing: '65' - '-44' ---
59int(109)
60--- testing: '65' - '1.2' ---
61float(63.8)
62--- testing: '65' - '-7.7' ---
63float(72.7)
64--- testing: '65' - 'abc' ---
65Unsupported operand types: string - string
66--- testing: '65' - '123abc' ---
67int(-58)
68--- testing: '65' - '123e5' ---
69float(-12299935)
70--- testing: '65' - '123e5xyz' ---
71float(-12299935)
72--- testing: '65' - ' 123abc' ---
73int(-58)
74--- testing: '65' - '123 abc' ---
75int(-58)
76--- testing: '65' - '123abc ' ---
77int(-58)
78--- testing: '65' - '3.4a' ---
79float(61.6)
80--- testing: '65' - 'a5.9' ---
81Unsupported operand types: string - string
82--- testing: '-44' - '0' ---
83int(-44)
84--- testing: '-44' - '65' ---
85int(-109)
86--- testing: '-44' - '-44' ---
87int(0)
88--- testing: '-44' - '1.2' ---
89float(-45.2)
90--- testing: '-44' - '-7.7' ---
91float(-36.3)
92--- testing: '-44' - 'abc' ---
93Unsupported operand types: string - string
94--- testing: '-44' - '123abc' ---
95int(-167)
96--- testing: '-44' - '123e5' ---
97float(-12300044)
98--- testing: '-44' - '123e5xyz' ---
99float(-12300044)
100--- testing: '-44' - ' 123abc' ---
101int(-167)
102--- testing: '-44' - '123 abc' ---
103int(-167)
104--- testing: '-44' - '123abc ' ---
105int(-167)
106--- testing: '-44' - '3.4a' ---
107float(-47.4)
108--- testing: '-44' - 'a5.9' ---
109Unsupported operand types: string - string
110--- testing: '1.2' - '0' ---
111float(1.2)
112--- testing: '1.2' - '65' ---
113float(-63.8)
114--- testing: '1.2' - '-44' ---
115float(45.2)
116--- testing: '1.2' - '1.2' ---
117float(0)
118--- testing: '1.2' - '-7.7' ---
119float(8.9)
120--- testing: '1.2' - 'abc' ---
121Unsupported operand types: string - string
122--- testing: '1.2' - '123abc' ---
123float(-121.8)
124--- testing: '1.2' - '123e5' ---
125float(-12299998.8)
126--- testing: '1.2' - '123e5xyz' ---
127float(-12299998.8)
128--- testing: '1.2' - ' 123abc' ---
129float(-121.8)
130--- testing: '1.2' - '123 abc' ---
131float(-121.8)
132--- testing: '1.2' - '123abc ' ---
133float(-121.8)
134--- testing: '1.2' - '3.4a' ---
135float(-2.2)
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(-72.7)
142--- testing: '-7.7' - '-44' ---
143float(36.3)
144--- testing: '-7.7' - '1.2' ---
145float(-8.9)
146--- testing: '-7.7' - '-7.7' ---
147float(0)
148--- testing: '-7.7' - 'abc' ---
149Unsupported operand types: string - string
150--- testing: '-7.7' - '123abc' ---
151float(-130.7)
152--- testing: '-7.7' - '123e5' ---
153float(-12300007.7)
154--- testing: '-7.7' - '123e5xyz' ---
155float(-12300007.7)
156--- testing: '-7.7' - ' 123abc' ---
157float(-130.7)
158--- testing: '-7.7' - '123 abc' ---
159float(-130.7)
160--- testing: '-7.7' - '123abc ' ---
161float(-130.7)
162--- testing: '-7.7' - '3.4a' ---
163float(-11.1)
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(58)
198--- testing: '123abc' - '-44' ---
199int(167)
200--- testing: '123abc' - '1.2' ---
201float(121.8)
202--- testing: '123abc' - '-7.7' ---
203float(130.7)
204--- testing: '123abc' - 'abc' ---
205Unsupported operand types: string - string
206--- testing: '123abc' - '123abc' ---
207int(0)
208--- testing: '123abc' - '123e5' ---
209float(-12299877)
210--- testing: '123abc' - '123e5xyz' ---
211float(-12299877)
212--- testing: '123abc' - ' 123abc' ---
213int(0)
214--- testing: '123abc' - '123 abc' ---
215int(0)
216--- testing: '123abc' - '123abc ' ---
217int(0)
218--- testing: '123abc' - '3.4a' ---
219float(119.6)
220--- testing: '123abc' - 'a5.9' ---
221Unsupported operand types: string - string
222--- testing: '123e5' - '0' ---
223float(12300000)
224--- testing: '123e5' - '65' ---
225float(12299935)
226--- testing: '123e5' - '-44' ---
227float(12300044)
228--- testing: '123e5' - '1.2' ---
229float(12299998.8)
230--- testing: '123e5' - '-7.7' ---
231float(12300007.7)
232--- testing: '123e5' - 'abc' ---
233Unsupported operand types: string - string
234--- testing: '123e5' - '123abc' ---
235float(12299877)
236--- testing: '123e5' - '123e5' ---
237float(0)
238--- testing: '123e5' - '123e5xyz' ---
239float(0)
240--- testing: '123e5' - ' 123abc' ---
241float(12299877)
242--- testing: '123e5' - '123 abc' ---
243float(12299877)
244--- testing: '123e5' - '123abc ' ---
245float(12299877)
246--- testing: '123e5' - '3.4a' ---
247float(12299996.6)
248--- testing: '123e5' - 'a5.9' ---
249Unsupported operand types: string - string
250--- testing: '123e5xyz' - '0' ---
251float(12300000)
252--- testing: '123e5xyz' - '65' ---
253float(12299935)
254--- testing: '123e5xyz' - '-44' ---
255float(12300044)
256--- testing: '123e5xyz' - '1.2' ---
257float(12299998.8)
258--- testing: '123e5xyz' - '-7.7' ---
259float(12300007.7)
260--- testing: '123e5xyz' - 'abc' ---
261Unsupported operand types: string - string
262--- testing: '123e5xyz' - '123abc' ---
263float(12299877)
264--- testing: '123e5xyz' - '123e5' ---
265float(0)
266--- testing: '123e5xyz' - '123e5xyz' ---
267float(0)
268--- testing: '123e5xyz' - ' 123abc' ---
269float(12299877)
270--- testing: '123e5xyz' - '123 abc' ---
271float(12299877)
272--- testing: '123e5xyz' - '123abc ' ---
273float(12299877)
274--- testing: '123e5xyz' - '3.4a' ---
275float(12299996.6)
276--- testing: '123e5xyz' - 'a5.9' ---
277Unsupported operand types: string - string
278--- testing: ' 123abc' - '0' ---
279int(123)
280--- testing: ' 123abc' - '65' ---
281int(58)
282--- testing: ' 123abc' - '-44' ---
283int(167)
284--- testing: ' 123abc' - '1.2' ---
285float(121.8)
286--- testing: ' 123abc' - '-7.7' ---
287float(130.7)
288--- testing: ' 123abc' - 'abc' ---
289Unsupported operand types: string - string
290--- testing: ' 123abc' - '123abc' ---
291int(0)
292--- testing: ' 123abc' - '123e5' ---
293float(-12299877)
294--- testing: ' 123abc' - '123e5xyz' ---
295float(-12299877)
296--- testing: ' 123abc' - ' 123abc' ---
297int(0)
298--- testing: ' 123abc' - '123 abc' ---
299int(0)
300--- testing: ' 123abc' - '123abc ' ---
301int(0)
302--- testing: ' 123abc' - '3.4a' ---
303float(119.6)
304--- testing: ' 123abc' - 'a5.9' ---
305Unsupported operand types: string - string
306--- testing: '123 abc' - '0' ---
307int(123)
308--- testing: '123 abc' - '65' ---
309int(58)
310--- testing: '123 abc' - '-44' ---
311int(167)
312--- testing: '123 abc' - '1.2' ---
313float(121.8)
314--- testing: '123 abc' - '-7.7' ---
315float(130.7)
316--- testing: '123 abc' - 'abc' ---
317Unsupported operand types: string - string
318--- testing: '123 abc' - '123abc' ---
319int(0)
320--- testing: '123 abc' - '123e5' ---
321float(-12299877)
322--- testing: '123 abc' - '123e5xyz' ---
323float(-12299877)
324--- testing: '123 abc' - ' 123abc' ---
325int(0)
326--- testing: '123 abc' - '123 abc' ---
327int(0)
328--- testing: '123 abc' - '123abc ' ---
329int(0)
330--- testing: '123 abc' - '3.4a' ---
331float(119.6)
332--- testing: '123 abc' - 'a5.9' ---
333Unsupported operand types: string - string
334--- testing: '123abc ' - '0' ---
335int(123)
336--- testing: '123abc ' - '65' ---
337int(58)
338--- testing: '123abc ' - '-44' ---
339int(167)
340--- testing: '123abc ' - '1.2' ---
341float(121.8)
342--- testing: '123abc ' - '-7.7' ---
343float(130.7)
344--- testing: '123abc ' - 'abc' ---
345Unsupported operand types: string - string
346--- testing: '123abc ' - '123abc' ---
347int(0)
348--- testing: '123abc ' - '123e5' ---
349float(-12299877)
350--- testing: '123abc ' - '123e5xyz' ---
351float(-12299877)
352--- testing: '123abc ' - ' 123abc' ---
353int(0)
354--- testing: '123abc ' - '123 abc' ---
355int(0)
356--- testing: '123abc ' - '123abc ' ---
357int(0)
358--- testing: '123abc ' - '3.4a' ---
359float(119.6)
360--- testing: '123abc ' - 'a5.9' ---
361Unsupported operand types: string - string
362--- testing: '3.4a' - '0' ---
363float(3.4)
364--- testing: '3.4a' - '65' ---
365float(-61.6)
366--- testing: '3.4a' - '-44' ---
367float(47.4)
368--- testing: '3.4a' - '1.2' ---
369float(2.2)
370--- testing: '3.4a' - '-7.7' ---
371float(11.1)
372--- testing: '3.4a' - 'abc' ---
373Unsupported operand types: string - string
374--- testing: '3.4a' - '123abc' ---
375float(-119.6)
376--- testing: '3.4a' - '123e5' ---
377float(-12299996.6)
378--- testing: '3.4a' - '123e5xyz' ---
379float(-12299996.6)
380--- testing: '3.4a' - ' 123abc' ---
381float(-119.6)
382--- testing: '3.4a' - '123 abc' ---
383float(-119.6)
384--- testing: '3.4a' - '123abc ' ---
385float(-119.6)
386--- testing: '3.4a' - '3.4a' ---
387float(0)
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