Re: Base64_encode

From: Date: Wed, 17 Oct 2001 12:36:28 +0000
Subject: Re: Base64_encode
References: 1  Groups: php.qa 
Request: Send a blank email to php-qa+get-3679@lists.php.net to get a copy of this message
Your code and the following snippet works fine for me (on Win2k with PHP-4.0.7RC3): <?php mt_srand ((double) microtime() * 1000000); $s=''; for($i=0; $i<1048576; $i++) { $s.=chr(mt_rand(0,255)); } echo "<pre>\n"; echo chunk_split(base64_encode($s)); echo "</pre>\n"; ?> Sander ----- Original Message ----- From: "Liz" <liz@xcalibur.co.uk> To: "'PHP Quality Assurance Team Mailing List'" <php-qa@lists.php.net> Sent: Wednesday, October 17, 2001 1:45 PM Subject: [PHP-QA] Base64_encode > Can anyone verify with me that the base64_encode doesn't seem to handle > >4K?? > > Such as.. The following causes PHP to crash under windows.. But seems OK > under linux. (Sorry its spammy, but this was my working example) > > <? > $mystring="<html> > <head> > <title>Purchasing Requirements</title> > <meta http-equiv=\"Content-Type\" content=\"text/html; > charset=iso-8859-1\"> > <link rel=\"stylesheet\" href=\"purchasing.css\" > type=\"text/css\"> > </head> > > <body bgcolor=\"#CC9966\" text=\"#000000\"> > <table width=\"100%\" border=\"0\" cellspacing=\"0\" > cellpadding=\"0\"> > <tr bgcolor=\"#993300\"> > <td height=\"20\" width=\"612\"><b><font > color=\"FAE6C9\" > size=\"+1\">PURCHASING REQUIREMENTS</font></b></td> > <td height=\"20\" width=\"235\" align=\"right\" > bgcolor=\"#993300\"> > <a href=\"tracker.php\"><font color=\"FAE6C9\" > size=\"2\">Track</font></a> > </td> > </tr> > </table> > <br> > <table width=\"100%\" border=\"0\" cellspacing=\"1\" > bgcolor=\"#993300\"> > <tr valign=\"top\"> > <td width=\"12%\" bgcolor=\"#FFCC99\" > height=\"18\"><font > size=\"2\"><b>Your Name</b></font></td> > <td width=\"34%\" bgcolor=\"#CC9966\" > height=\"18\"><font > size=\"2\">$username > </font></td> > <td width=\"12%\" bgcolor=\"#FFCC99\" > height=\"18\"><font > size=\"2\"><b>Department</b></font></td> > <td height=\"18\" bgcolor=\"#CC9966\" > colspan=\"3\"><font > size=\"2\">$department > </font></td> > </tr> > <tr valign=\"top\"> > <td bgcolor=\"#FFCC99\"><font > size=\"2\"><b>Email</b></font></td> > <td bgcolor=\"#CC9966\"><font size=\"2\">$useremail > </font></td> > <td colspan=\"4\" bgcolor=\"#CC9966\" > rowspan=\"3\">&nbsp;</td> > </tr> > <tr valign=\"top\"> > <td bgcolor=\"#FFCC99\"><font size=\"2\"><b>Phone > #</b></font></td> > <td bgcolor=\"#CC9966\"><font size=\"2\">$userphone > </font></td> > </tr> > <tr valign=\"top\"> > <td bgcolor=\"#FFCC99\"><font > size=\"2\"><b>Authoriser</b></font></td> > <td bgcolor=\"#CC9966\"><font size=\"2\"> $authoriser > </font></td> > </tr> > <tr valign=\"top\"> > <td bgcolor=\"#FFCC99\"> > <p><font size=\"2\"><b>Type of > request</b></font><font > size=\"2\"><b>st</b> </font></p> > </td> > <td bgcolor=\"#CC9966\"><font size=\"2\">$requesttype > </font></td> > <td colspan=\"4\" bgcolor=\"#CC9966\"><font > size=\"2\">The items > will be $methodtype > <br> > The items will be $recharge to $rechargedto > </font></td> > </tr> > <tr valign=\"top\" bgcolor=\"#FFCC99\"> > <td colspan=\"4\" bgcolor=\"#FFCC99\"><b><font > size=\"2\">Description</font></b></td> > <td><b><font > size=\"2\">Quantity</font></b></td> > <td><b><font size=\"2\">Cost</font></b></td> > </tr>"; > $tcost=0; > $titems=0; > for ($i=0; $i<count($description); $i++) > > $mystring .=" > <tr bgcolor=\"#CC9966\"> > <td colspan=\"4\"><font > size=\"2\">".$description["$i"]." > </font>&nbsp;</td> > <td width=\"13%\"> <font > size=\"2\">".$quantity["$i"]." > </font>&nbsp;</td> > <td width=\"11%\"> <font > size=\"2\">".$cost["$i"]." > </font>&nbsp;</td> > </tr>"; > $titems=$titems+doubleval($quantity["$i"]); > $tcost=$tcost+(doubleval($cost["$i"])*doubleval($quantity["$i"])); > } > $mystring .=" <tr bgcolor=\"#CC9966\"> > <td colspan=\"4\" bgcolor=\"#FFCC99\"><font > size=\"2\"> > <b>TOTAL</b> </font>&nbsp;</td> > <td width=\"13%\"> <font size=\"2\"> > <b>$titems</b> > </font>&nbsp;</td> > <td width=\"11%\"> <font size=\"2\"> > <b>$tcost</b> > </font>&nbsp;</td> > </tr> > <tr valign=\"top\" bgcolor=\"#FFCC99\"> > <td colspan=\"6\"><font > size=\"2\"><b>Justification</b></font></td> > </tr> > <tr valign=\"top\"> > <td colspan=\"6\" bgcolor=\"#CC9966\"> > <font size=\"2\">$justification</font> > </td> > </tr> > <tr valign=\"top\"> > <td bgcolor=\"#FFCC99\"><b><font size=\"2\">Date > required</font></b></td> > <td colspan=\"5\" bgcolor=\"#CC9966\"><font > size=\"2\"> > <font size=\"2\">$daterequired</font> > </font></td> > </tr> > </table> > </body> > </html> > "; > $newstr=base64_encode($mystring); > ?> > > > -- > PHP Quality Assurance Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-qa-unsubscribe@lists.php.net > For additional commands, e-mail: php-qa-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.qa (#3679) next »