回答編集履歴

1

具体的に

2019/07/17 07:34

投稿

yambejp
yambejp

スコア114843

test CHANGED
@@ -45,3 +45,93 @@
45
45
  そもそも各処理が標準出力せずに文字列をreturnするようにすれば
46
46
 
47
47
  バッファリング自体不要です
48
+
49
+
50
+
51
+ # 具体的に
52
+
53
+ ```PHP
54
+
55
+ <?PHP
56
+
57
+ function get_page($page) {
58
+
59
+ return str_replace('あ', 'ああ', $page);
60
+
61
+ }
62
+
63
+ function get_content($content) {
64
+
65
+ return str_replace('い', 'いい', $content);
66
+
67
+ }
68
+
69
+ function get_header($header) {
70
+
71
+ return str_replace('う', 'うう', $header);
72
+
73
+ }
74
+
75
+ function get_footer($footer) {
76
+
77
+ return str_replace('え', 'ええ', $footer);
78
+
79
+ }
80
+
81
+
82
+
83
+ $content="";
84
+
85
+ ob_start('get_page');
86
+
87
+ print "1.あいうえお\n";
88
+
89
+ $content.=ob_get_contents();
90
+
91
+ ob_clean();
92
+
93
+
94
+
95
+ ob_start('get_header');
96
+
97
+ print "2.あいうえお\n";
98
+
99
+ $content.=ob_get_contents();
100
+
101
+ ob_clean();
102
+
103
+
104
+
105
+ ob_start('get_content');
106
+
107
+ print "3.あいうえお\n";
108
+
109
+ $content.=ob_get_contents();
110
+
111
+ ob_clean();
112
+
113
+
114
+
115
+ ob_start('get_footer');
116
+
117
+ print "4.あいうえお\n";
118
+
119
+ $content.=ob_get_contents();
120
+
121
+ ob_clean();
122
+
123
+
124
+
125
+ print $content;
126
+
127
+ ```
128
+
129
+ 出力
130
+
131
+ 1.ああいいううええお
132
+
133
+ 2.ああいいううええお
134
+
135
+ 3.ああいいううええお
136
+
137
+ 4.ああいいううええお