xref: /PHP-8.2/tests/lang/028.phpt (revision f8d79582)
1--TEST--
2Testing calling user-level functions from C
3--FILE--
4<?php
5
6error_reporting(1023);
7
8function print_stuff($stuff)
9{
10    print $stuff;
11}
12
13
14function still_working()
15{
16    return "I'm still alive";
17}
18
19function dafna()
20{
21    static $foo = 0;
22
23    print "Dafna!\n";
24    print call_user_func("still_working")."\n";
25    $foo++;
26    return (string) $foo;
27}
28
29
30class dafna_class {
31    function __construct() {
32        $this->myname = "Dafna";
33    }
34    function GetMyName() {
35        return $this->myname;
36    }
37    function SetMyName($name) {
38        $this->myname = $name;
39    }
40};
41
42for ($i=0; $i<200; $i++):
43    print "$i\n";
44    call_user_func("dafna");
45    call_user_func("print_stuff","Hey there!!\n");
46    print "$i\n";
47endfor;
48
49
50$dafna = new dafna_class();
51
52print $name=call_user_func(array(&$dafna,"GetMyName"));
53print "\n";
54
55?>
56--EXPECT--
570
58Dafna!
59I'm still alive
60Hey there!!
610
621
63Dafna!
64I'm still alive
65Hey there!!
661
672
68Dafna!
69I'm still alive
70Hey there!!
712
723
73Dafna!
74I'm still alive
75Hey there!!
763
774
78Dafna!
79I'm still alive
80Hey there!!
814
825
83Dafna!
84I'm still alive
85Hey there!!
865
876
88Dafna!
89I'm still alive
90Hey there!!
916
927
93Dafna!
94I'm still alive
95Hey there!!
967
978
98Dafna!
99I'm still alive
100Hey there!!
1018
1029
103Dafna!
104I'm still alive
105Hey there!!
1069
10710
108Dafna!
109I'm still alive
110Hey there!!
11110
11211
113Dafna!
114I'm still alive
115Hey there!!
11611
11712
118Dafna!
119I'm still alive
120Hey there!!
12112
12213
123Dafna!
124I'm still alive
125Hey there!!
12613
12714
128Dafna!
129I'm still alive
130Hey there!!
13114
13215
133Dafna!
134I'm still alive
135Hey there!!
13615
13716
138Dafna!
139I'm still alive
140Hey there!!
14116
14217
143Dafna!
144I'm still alive
145Hey there!!
14617
14718
148Dafna!
149I'm still alive
150Hey there!!
15118
15219
153Dafna!
154I'm still alive
155Hey there!!
15619
15720
158Dafna!
159I'm still alive
160Hey there!!
16120
16221
163Dafna!
164I'm still alive
165Hey there!!
16621
16722
168Dafna!
169I'm still alive
170Hey there!!
17122
17223
173Dafna!
174I'm still alive
175Hey there!!
17623
17724
178Dafna!
179I'm still alive
180Hey there!!
18124
18225
183Dafna!
184I'm still alive
185Hey there!!
18625
18726
188Dafna!
189I'm still alive
190Hey there!!
19126
19227
193Dafna!
194I'm still alive
195Hey there!!
19627
19728
198Dafna!
199I'm still alive
200Hey there!!
20128
20229
203Dafna!
204I'm still alive
205Hey there!!
20629
20730
208Dafna!
209I'm still alive
210Hey there!!
21130
21231
213Dafna!
214I'm still alive
215Hey there!!
21631
21732
218Dafna!
219I'm still alive
220Hey there!!
22132
22233
223Dafna!
224I'm still alive
225Hey there!!
22633
22734
228Dafna!
229I'm still alive
230Hey there!!
23134
23235
233Dafna!
234I'm still alive
235Hey there!!
23635
23736
238Dafna!
239I'm still alive
240Hey there!!
24136
24237
243Dafna!
244I'm still alive
245Hey there!!
24637
24738
248Dafna!
249I'm still alive
250Hey there!!
25138
25239
253Dafna!
254I'm still alive
255Hey there!!
25639
25740
258Dafna!
259I'm still alive
260Hey there!!
26140
26241
263Dafna!
264I'm still alive
265Hey there!!
26641
26742
268Dafna!
269I'm still alive
270Hey there!!
27142
27243
273Dafna!
274I'm still alive
275Hey there!!
27643
27744
278Dafna!
279I'm still alive
280Hey there!!
28144
28245
283Dafna!
284I'm still alive
285Hey there!!
28645
28746
288Dafna!
289I'm still alive
290Hey there!!
29146
29247
293Dafna!
294I'm still alive
295Hey there!!
29647
29748
298Dafna!
299I'm still alive
300Hey there!!
30148
30249
303Dafna!
304I'm still alive
305Hey there!!
30649
30750
308Dafna!
309I'm still alive
310Hey there!!
31150
31251
313Dafna!
314I'm still alive
315Hey there!!
31651
31752
318Dafna!
319I'm still alive
320Hey there!!
32152
32253
323Dafna!
324I'm still alive
325Hey there!!
32653
32754
328Dafna!
329I'm still alive
330Hey there!!
33154
33255
333Dafna!
334I'm still alive
335Hey there!!
33655
33756
338Dafna!
339I'm still alive
340Hey there!!
34156
34257
343Dafna!
344I'm still alive
345Hey there!!
34657
34758
348Dafna!
349I'm still alive
350Hey there!!
35158
35259
353Dafna!
354I'm still alive
355Hey there!!
35659
35760
358Dafna!
359I'm still alive
360Hey there!!
36160
36261
363Dafna!
364I'm still alive
365Hey there!!
36661
36762
368Dafna!
369I'm still alive
370Hey there!!
37162
37263
373Dafna!
374I'm still alive
375Hey there!!
37663
37764
378Dafna!
379I'm still alive
380Hey there!!
38164
38265
383Dafna!
384I'm still alive
385Hey there!!
38665
38766
388Dafna!
389I'm still alive
390Hey there!!
39166
39267
393Dafna!
394I'm still alive
395Hey there!!
39667
39768
398Dafna!
399I'm still alive
400Hey there!!
40168
40269
403Dafna!
404I'm still alive
405Hey there!!
40669
40770
408Dafna!
409I'm still alive
410Hey there!!
41170
41271
413Dafna!
414I'm still alive
415Hey there!!
41671
41772
418Dafna!
419I'm still alive
420Hey there!!
42172
42273
423Dafna!
424I'm still alive
425Hey there!!
42673
42774
428Dafna!
429I'm still alive
430Hey there!!
43174
43275
433Dafna!
434I'm still alive
435Hey there!!
43675
43776
438Dafna!
439I'm still alive
440Hey there!!
44176
44277
443Dafna!
444I'm still alive
445Hey there!!
44677
44778
448Dafna!
449I'm still alive
450Hey there!!
45178
45279
453Dafna!
454I'm still alive
455Hey there!!
45679
45780
458Dafna!
459I'm still alive
460Hey there!!
46180
46281
463Dafna!
464I'm still alive
465Hey there!!
46681
46782
468Dafna!
469I'm still alive
470Hey there!!
47182
47283
473Dafna!
474I'm still alive
475Hey there!!
47683
47784
478Dafna!
479I'm still alive
480Hey there!!
48184
48285
483Dafna!
484I'm still alive
485Hey there!!
48685
48786
488Dafna!
489I'm still alive
490Hey there!!
49186
49287
493Dafna!
494I'm still alive
495Hey there!!
49687
49788
498Dafna!
499I'm still alive
500Hey there!!
50188
50289
503Dafna!
504I'm still alive
505Hey there!!
50689
50790
508Dafna!
509I'm still alive
510Hey there!!
51190
51291
513Dafna!
514I'm still alive
515Hey there!!
51691
51792
518Dafna!
519I'm still alive
520Hey there!!
52192
52293
523Dafna!
524I'm still alive
525Hey there!!
52693
52794
528Dafna!
529I'm still alive
530Hey there!!
53194
53295
533Dafna!
534I'm still alive
535Hey there!!
53695
53796
538Dafna!
539I'm still alive
540Hey there!!
54196
54297
543Dafna!
544I'm still alive
545Hey there!!
54697
54798
548Dafna!
549I'm still alive
550Hey there!!
55198
55299
553Dafna!
554I'm still alive
555Hey there!!
55699
557100
558Dafna!
559I'm still alive
560Hey there!!
561100
562101
563Dafna!
564I'm still alive
565Hey there!!
566101
567102
568Dafna!
569I'm still alive
570Hey there!!
571102
572103
573Dafna!
574I'm still alive
575Hey there!!
576103
577104
578Dafna!
579I'm still alive
580Hey there!!
581104
582105
583Dafna!
584I'm still alive
585Hey there!!
586105
587106
588Dafna!
589I'm still alive
590Hey there!!
591106
592107
593Dafna!
594I'm still alive
595Hey there!!
596107
597108
598Dafna!
599I'm still alive
600Hey there!!
601108
602109
603Dafna!
604I'm still alive
605Hey there!!
606109
607110
608Dafna!
609I'm still alive
610Hey there!!
611110
612111
613Dafna!
614I'm still alive
615Hey there!!
616111
617112
618Dafna!
619I'm still alive
620Hey there!!
621112
622113
623Dafna!
624I'm still alive
625Hey there!!
626113
627114
628Dafna!
629I'm still alive
630Hey there!!
631114
632115
633Dafna!
634I'm still alive
635Hey there!!
636115
637116
638Dafna!
639I'm still alive
640Hey there!!
641116
642117
643Dafna!
644I'm still alive
645Hey there!!
646117
647118
648Dafna!
649I'm still alive
650Hey there!!
651118
652119
653Dafna!
654I'm still alive
655Hey there!!
656119
657120
658Dafna!
659I'm still alive
660Hey there!!
661120
662121
663Dafna!
664I'm still alive
665Hey there!!
666121
667122
668Dafna!
669I'm still alive
670Hey there!!
671122
672123
673Dafna!
674I'm still alive
675Hey there!!
676123
677124
678Dafna!
679I'm still alive
680Hey there!!
681124
682125
683Dafna!
684I'm still alive
685Hey there!!
686125
687126
688Dafna!
689I'm still alive
690Hey there!!
691126
692127
693Dafna!
694I'm still alive
695Hey there!!
696127
697128
698Dafna!
699I'm still alive
700Hey there!!
701128
702129
703Dafna!
704I'm still alive
705Hey there!!
706129
707130
708Dafna!
709I'm still alive
710Hey there!!
711130
712131
713Dafna!
714I'm still alive
715Hey there!!
716131
717132
718Dafna!
719I'm still alive
720Hey there!!
721132
722133
723Dafna!
724I'm still alive
725Hey there!!
726133
727134
728Dafna!
729I'm still alive
730Hey there!!
731134
732135
733Dafna!
734I'm still alive
735Hey there!!
736135
737136
738Dafna!
739I'm still alive
740Hey there!!
741136
742137
743Dafna!
744I'm still alive
745Hey there!!
746137
747138
748Dafna!
749I'm still alive
750Hey there!!
751138
752139
753Dafna!
754I'm still alive
755Hey there!!
756139
757140
758Dafna!
759I'm still alive
760Hey there!!
761140
762141
763Dafna!
764I'm still alive
765Hey there!!
766141
767142
768Dafna!
769I'm still alive
770Hey there!!
771142
772143
773Dafna!
774I'm still alive
775Hey there!!
776143
777144
778Dafna!
779I'm still alive
780Hey there!!
781144
782145
783Dafna!
784I'm still alive
785Hey there!!
786145
787146
788Dafna!
789I'm still alive
790Hey there!!
791146
792147
793Dafna!
794I'm still alive
795Hey there!!
796147
797148
798Dafna!
799I'm still alive
800Hey there!!
801148
802149
803Dafna!
804I'm still alive
805Hey there!!
806149
807150
808Dafna!
809I'm still alive
810Hey there!!
811150
812151
813Dafna!
814I'm still alive
815Hey there!!
816151
817152
818Dafna!
819I'm still alive
820Hey there!!
821152
822153
823Dafna!
824I'm still alive
825Hey there!!
826153
827154
828Dafna!
829I'm still alive
830Hey there!!
831154
832155
833Dafna!
834I'm still alive
835Hey there!!
836155
837156
838Dafna!
839I'm still alive
840Hey there!!
841156
842157
843Dafna!
844I'm still alive
845Hey there!!
846157
847158
848Dafna!
849I'm still alive
850Hey there!!
851158
852159
853Dafna!
854I'm still alive
855Hey there!!
856159
857160
858Dafna!
859I'm still alive
860Hey there!!
861160
862161
863Dafna!
864I'm still alive
865Hey there!!
866161
867162
868Dafna!
869I'm still alive
870Hey there!!
871162
872163
873Dafna!
874I'm still alive
875Hey there!!
876163
877164
878Dafna!
879I'm still alive
880Hey there!!
881164
882165
883Dafna!
884I'm still alive
885Hey there!!
886165
887166
888Dafna!
889I'm still alive
890Hey there!!
891166
892167
893Dafna!
894I'm still alive
895Hey there!!
896167
897168
898Dafna!
899I'm still alive
900Hey there!!
901168
902169
903Dafna!
904I'm still alive
905Hey there!!
906169
907170
908Dafna!
909I'm still alive
910Hey there!!
911170
912171
913Dafna!
914I'm still alive
915Hey there!!
916171
917172
918Dafna!
919I'm still alive
920Hey there!!
921172
922173
923Dafna!
924I'm still alive
925Hey there!!
926173
927174
928Dafna!
929I'm still alive
930Hey there!!
931174
932175
933Dafna!
934I'm still alive
935Hey there!!
936175
937176
938Dafna!
939I'm still alive
940Hey there!!
941176
942177
943Dafna!
944I'm still alive
945Hey there!!
946177
947178
948Dafna!
949I'm still alive
950Hey there!!
951178
952179
953Dafna!
954I'm still alive
955Hey there!!
956179
957180
958Dafna!
959I'm still alive
960Hey there!!
961180
962181
963Dafna!
964I'm still alive
965Hey there!!
966181
967182
968Dafna!
969I'm still alive
970Hey there!!
971182
972183
973Dafna!
974I'm still alive
975Hey there!!
976183
977184
978Dafna!
979I'm still alive
980Hey there!!
981184
982185
983Dafna!
984I'm still alive
985Hey there!!
986185
987186
988Dafna!
989I'm still alive
990Hey there!!
991186
992187
993Dafna!
994I'm still alive
995Hey there!!
996187
997188
998Dafna!
999I'm still alive
1000Hey there!!
1001188
1002189
1003Dafna!
1004I'm still alive
1005Hey there!!
1006189
1007190
1008Dafna!
1009I'm still alive
1010Hey there!!
1011190
1012191
1013Dafna!
1014I'm still alive
1015Hey there!!
1016191
1017192
1018Dafna!
1019I'm still alive
1020Hey there!!
1021192
1022193
1023Dafna!
1024I'm still alive
1025Hey there!!
1026193
1027194
1028Dafna!
1029I'm still alive
1030Hey there!!
1031194
1032195
1033Dafna!
1034I'm still alive
1035Hey there!!
1036195
1037196
1038Dafna!
1039I'm still alive
1040Hey there!!
1041196
1042197
1043Dafna!
1044I'm still alive
1045Hey there!!
1046197
1047198
1048Dafna!
1049I'm still alive
1050Hey there!!
1051198
1052199
1053Dafna!
1054I'm still alive
1055Hey there!!
1056199
1057Dafna
1058