3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getmsg($mbox,$mid) { global $charset,$htmlmsg,$plainmsg,$attachments; $htmlmsg = $plainmsg = $charset = ''; $attachments = array(); $h = imap_header($mbox,$mid); $s = imap_fetchstructure($mbox,$mid); if (!$s->parts) getpart($mbox,$mid,$s,0); else { foreach ($s->parts as $partno0=>$p) getpart($mbox,$mid,$p,$partno0+1); } echo $htmlmsg; } function getpart($mbox,$mid,$p,$partno) { global $htmlmsg,$plainmsg,$charset,$attachments; $data = ($partno)? imap_fetchbody($mbox,$mid,$partno): imap_body($mbox,$mid); if ($p->encoding==4) $data = quoted_printable_decode($data); elseif ($p->encoding==3) $data = base64_decode($data); $params = array(); if ($p->parameters) foreach ($p->parameters as $x) $params[strtolower($x->attribute)] = $x->value; if ($p->dparameters) foreach ($p->dparameters as $x) $params[strtolower($x->attribute)] = $x->value; if ($params['filename'] || $params['name']) { $filename = ($params['filename'])? $params['filename'] : $params['name']; $attachments[$filename] = $data; } if ($p->type==0 && $data) { if (strtolower($p->subtype)=='plain') $plainmsg. = trim($data) ."\n\n"; else $htmlmsg. = $data ."<br><br>"; $charset = $params['charset']; } elseif ($p->type==2 && $data) { $plainmsg. = $data."\n\n"; } if ($p->parts) { foreach ($p->parts as $partno0=>$p2) getpart($mbox,$mid,$p2,$partno.'.'.($partno0+1)); } }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.4.32
Parse error: syntax error, unexpected '=' in /in/aP8mN on line 48
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '=' in /in/aP8mN on line 48
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/aP8mN on line 48
Process exited with code 255.