public static function generateFile($filename, $size)
    {
        if (file_exists($filename) && $size == filesize($filename)) {
            echo $filename . " already exists, no need to create again. ";
            return;
        }
        $part_size = 1 * 1024 * 1024;
        $fp = fopen($filename, "w");
        $characters = <<<BBB
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
BBB;

        $charactersLength = strlen($characters);
        if ($fp) {
            while ($size > 0) {
                if ($size < $part_size) {
                    $write_size = $size;
                } else {
                    $write_size = $part_size;
                }
                $size -= $write_size;
                $a = $characters[rand(0, $charactersLength - 1)];
                $content = str_repeat($a, $write_size);
                $flag = fwrite($fp, $content);
                if (!$flag) {
                    echo "write to " . $filename . " failed. <br>";
                    break;
                }
            }
        } else {
            echo "open " . $filename . " failed. <br>";
        }
        fclose($fp);
    }
public static function generateFile($filename, $size)
    {
        if (file_exists($filename) && $size == filesize($filename)) {
            echo $filename . " already exists, no need to create again. ";
            return;
        }
        $part_size = 1 * 1024 * 1024;
        $fp = fopen($filename, "w");
        $characters = <<<BBB
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
BBB;

        $charactersLength = strlen($characters);
        if ($fp) {
            while ($size > 0) {
                if ($size < $part_size) {
                    $write_size = $size;
                } else {
                    $write_size = $part_size;
                }
                $size -= $write_size;
                $a = $characters[rand(0, $charactersLength - 1)];
                $content = str_repeat($a, $write_size);
                $flag = fwrite($fp, $content);
                if (!$flag) {
                    echo "write to " . $filename . " failed. <br>";
                    break;
                }
            }
        } else {
            echo "open " . $filename . " failed. <br>";
        }
        fclose($fp);
    }
public static function generateFile ( $ filename , $ size ) { if ( file_exists ( $ filename ) && $ size == filesize ( $ filename ) ) { echo $ filename . " already exists, no need to create again. " ; return ; } $ part_size = 1 * 1024 * 1024 ; $ fp = fopen ( $ filename , "w" ) ; $ characters =  <<<BBB
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
BBB ; $ charactersLength = strlen ( $ characters ) ; if ( $ fp ) { while ( $ size > 0 ) { if ( $ size < $ part_size ) { $ write_size = $ size ; } else { $ write_size = $ part_size ; } $ size -= $ write_size ; $ a = $ characters [ rand ( 0 , $ charactersLength - 1 ) ] ; $ content = str_repeat ( $ a , $ write_size ) ; $ flag = fwrite ( $ fp , $ content ) ; if ( ! $ flag ) { echo "write to " . $ filename . " failed. <br>" ; break ; } } } else { echo "open " . $ filename . " failed. <br>" ; } fclose ( $ fp ) ; }
This is a method for test only. DO NOT USE.

@param $filename
@param $size
This is a method for test only . DO NOT USE .