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