3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Command line utility to use dompdf. * Can also be used with HTTP GET parameters * * @package dompdf * @link http://dompdf.github.com/ * @author Benj Carson <benjcarson@digitaljunkies.ca> * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License */ /** * Display command line usage */ function dompdf_usage() { $default_paper_size = DOMPDF_DEFAULT_PAPER_SIZE; echo <<<EOD Usage: {$_SERVER["argv"][0]} [options] html_file html_file can be a filename, a url if fopen_wrappers are enabled, or the '-' character to read from standard input. Options: -h Show this message -l List available paper sizes -p size Paper size; something like 'letter', 'A4', 'legal', etc. The default is '$default_paper_size' -o orientation Either 'portrait' or 'landscape'. Default is 'portrait' -b path Set the 'document root' of the html_file. Relative urls (for stylesheets) are resolved using this directory. Default is the directory of html_file. -f file The output filename. Default is the input [html_file].pdf -v Verbose: display html parsing warnings and file not found errors. -d Very verbose: display oodles of debugging output: every frame in the tree printed to stdout. -t Comma separated list of debugging types (page-break,reflow,split) EOD; exit; } /** * Parses command line options * * @return array The command line options */ function getoptions() { $opts = array(); if ( $_SERVER["argc"] == 1 ) return $opts; $i = 1; while ($i < $_SERVER["argc"]) { switch ($_SERVER["argv"][$i]) { case "--help": case "-h": $opts["h"] = true; $i++; break; case "-l": $opts["l"] = true; $i++; break; case "-p": if ( !isset($_SERVER["argv"][$i+1]) ) die("-p switch requires a size parameter\n"); $opts["p"] = $_SERVER["argv"][$i+1]; $i += 2; break; case "-o": if ( !isset($_SERVER["argv"][$i+1]) ) die("-o switch requires an orientation parameter\n"); $opts["o"] = $_SERVER["argv"][$i+1]; $i += 2; break; case "-b": if ( !isset($_SERVER["argv"][$i+1]) ) die("-b switch requires a path parameter\n"); $opts["b"] = $_SERVER["argv"][$i+1]; $i += 2; break; case "-f": if ( !isset($_SERVER["argv"][$i+1]) ) die("-f switch requires a filename parameter\n"); $opts["f"] = $_SERVER["argv"][$i+1]; $i += 2; break; case "-v": $opts["v"] = true; $i++; break; case "-d": $opts["d"] = true; $i++; break; case "-t": if ( !isset($_SERVER['argv'][$i + 1]) ) die("-t switch requires a comma separated list of types\n"); $opts["t"] = $_SERVER['argv'][$i+1]; $i += 2; break; default: $opts["filename"] = $_SERVER["argv"][$i]; $i++; break; } } return $opts; } require_once("https://raw.githubusercontent.com/dompdf/dompdf/master/dompdf_config.inc.php"); global $_dompdf_show_warnings, $_dompdf_debug, $_DOMPDF_DEBUG_TYPES; $sapi = php_sapi_name(); $options = array(); switch ( $sapi ) { case "cli": $opts = getoptions(); if ( isset($opts["h"]) || (!isset($opts["filename"]) && !isset($opts["l"])) ) { dompdf_usage(); exit; } if ( isset($opts["l"]) ) { echo "\nUnderstood paper sizes:\n"; foreach (array_keys(CPDF_Adapter::$PAPER_SIZES) as $size) echo " " . mb_strtoupper($size) . "\n"; exit; } $file = $opts["filename"]; if ( isset($opts["p"]) ) $paper = $opts["p"]; else $paper = DOMPDF_DEFAULT_PAPER_SIZE; if ( isset($opts["o"]) ) $orientation = $opts["o"]; else $orientation = "portrait"; if ( isset($opts["b"]) ) $base_path = $opts["b"]; if ( isset($opts["f"]) ) $outfile = $opts["f"]; else { if ( $file === "-" ) $outfile = "dompdf_out.pdf"; else $outfile = str_ireplace(array(".html", ".htm", ".php"), "", $file) . ".pdf"; } if ( isset($opts["v"]) ) $_dompdf_show_warnings = true; if ( isset($opts["d"]) ) { $_dompdf_show_warnings = true; $_dompdf_debug = true; } if ( isset($opts['t']) ) { $arr = split(',',$opts['t']); $types = array(); foreach ($arr as $type) $types[ trim($type) ] = 1; $_DOMPDF_DEBUG_TYPES = $types; } $save_file = true; break; default: if ( isset($_GET["input_file"]) ) $file = rawurldecode($_GET["input_file"]); else throw new DOMPDF_Exception("An input file is required (i.e. input_file _GET variable)."); if ( isset($_GET["paper"]) ) $paper = rawurldecode($_GET["paper"]); else $paper = DOMPDF_DEFAULT_PAPER_SIZE; if ( isset($_GET["orientation"]) ) $orientation = rawurldecode($_GET["orientation"]); else $orientation = "portrait"; if ( isset($_GET["base_path"]) ) { $base_path = rawurldecode($_GET["base_path"]); $file = $base_path . $file; # Set the input file } if ( isset($_GET["options"]) ) { $options = $_GET["options"]; } $file_parts = explode_url($file); /* Check to see if the input file is local and, if so, that the base path falls within that specified by DOMDPF_CHROOT */ if(($file_parts['protocol'] == '' || $file_parts['protocol'] === 'file://')) { $file = realpath($file); if ( strpos($file, DOMPDF_CHROOT) !== 0 ) { throw new DOMPDF_Exception("Permission denied on $file. The file could not be found under the directory specified by DOMPDF_CHROOT."); } } if($file_parts['protocol'] === 'php://') { throw new DOMPDF_Exception("Permission denied on $file. This script does not allow PHP streams."); } $outfile = "dompdf_out.pdf"; # Don't allow them to set the output file $save_file = false; # Don't save the file break; } $dompdf = new DOMPDF(); if ( $file === "-" ) { $str = ""; while ( !feof(STDIN) ) $str .= fread(STDIN, 4096); $dompdf->load_html($str); } else $dompdf->load_html_file($file); if ( isset($base_path) ) { $dompdf->set_base_path($base_path); } $dompdf->set_paper($paper, $orientation); $dompdf->render(); if ( $_dompdf_show_warnings ) { global $_dompdf_warnings; foreach ($_dompdf_warnings as $msg) echo $msg . "\n"; echo $dompdf->get_canvas()->get_cpdf()->messages; flush(); } if ( $save_file ) { // if ( !is_writable($outfile) ) // throw new DOMPDF_Exception("'$outfile' is not writable."); if ( strtolower(DOMPDF_PDF_BACKEND) === "gd" ) $outfile = str_replace(".pdf", ".png", $outfile); list($proto, $host, $path, $file) = explode_url($outfile); if ( $proto != "" ) // i.e. not file:// $outfile = $file; // just save it locally, FIXME? could save it like wget: ./host/basepath/file $outfile = realpath(dirname($outfile)) . DIRECTORY_SEPARATOR . basename($outfile); if ( strpos($outfile, DOMPDF_CHROOT) !== 0 ) throw new DOMPDF_Exception("Permission denied."); file_put_contents($outfile, $dompdf->output( array("compress" => 0) )); exit(0); } if ( !headers_sent() ) { $dompdf->stream($outfile, $options); }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0120.00618.43
8.3.50.0150.00821.28
8.3.40.0120.00318.96
8.3.30.0110.00719.35
8.3.20.0080.00020.29
8.3.10.0080.00023.54
8.3.00.0000.00819.38
8.2.180.0160.00616.88
8.2.170.0070.00722.96
8.2.160.0110.00420.66
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0030.00626.16
8.2.120.0070.00320.62
8.2.110.0030.00620.64
8.2.100.0110.00018.28
8.2.90.0000.00819.30
8.2.80.0030.00517.97
8.2.70.0040.00417.75
8.2.60.0090.00317.93
8.2.50.0100.00318.07
8.2.40.0050.00519.75
8.2.30.0070.00018.26
8.2.20.0040.00417.98
8.2.10.0030.00518.29
8.2.00.0060.00317.89
8.1.280.0140.00725.92
8.1.270.0000.00922.14
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0090.00023.67
8.1.230.0060.00619.33
8.1.220.0000.00917.77
8.1.210.0060.00318.77
8.1.200.0030.00717.35
8.1.190.0030.00517.35
8.1.180.0040.00418.10
8.1.170.0030.00918.77
8.1.160.0000.00822.33
8.1.150.0040.00419.02
8.1.140.0030.00517.60
8.1.130.0000.00717.93
8.1.120.0040.00417.61
8.1.110.0030.00617.51
8.1.100.0040.00417.62
8.1.90.0000.00717.54
8.1.80.0040.00417.51
8.1.70.0050.00217.57
8.1.60.0060.00317.69
8.1.50.0000.00817.63
8.1.40.0060.00317.61
8.1.30.0000.00817.69
8.1.20.0040.00417.75
8.1.10.0000.00817.71
8.1.00.0000.00817.66
8.0.300.0040.00418.77
8.0.290.0090.00017.00
8.0.280.0040.00418.71
8.0.270.0040.00417.03
8.0.260.0030.00317.45
8.0.250.0040.00417.21
8.0.240.0030.00317.11
8.0.230.0030.00317.23
8.0.220.0040.00417.18
8.0.210.0070.00017.16
8.0.200.0070.00017.23
8.0.190.0040.00717.24
8.0.180.0030.00617.10
8.0.170.0040.00417.27
8.0.160.0030.00517.08
8.0.150.0040.00417.05
8.0.140.0070.00017.15
8.0.130.0000.00613.59
8.0.120.0040.00417.05
8.0.110.0050.00317.16
8.0.100.0030.00517.18
8.0.90.0040.00417.22
8.0.80.0100.00717.14
8.0.70.0040.00417.00
8.0.60.0040.00417.14
8.0.50.0080.00017.07
8.0.30.0110.00917.40
8.0.20.0130.00717.43
8.0.10.0000.00717.15
8.0.00.0100.00816.81
7.4.330.0030.00315.02
7.4.320.0070.00016.73
7.4.300.0000.00716.76
7.4.290.0030.00516.66
7.4.280.0080.00316.66
7.4.270.0000.00716.78
7.4.260.0000.01116.57
7.4.250.0040.00416.72
7.4.240.0030.00516.74
7.4.230.0000.00716.70
7.4.220.0060.01216.73
7.4.210.0060.00916.69
7.4.200.0050.00216.77
7.4.160.0060.00916.74
7.4.150.0170.00317.40
7.4.140.0130.01417.86
7.4.130.0150.00816.68
7.4.120.0100.00816.68
7.4.110.0110.00716.63
7.4.100.0090.00916.53
7.4.90.0070.01116.65
7.4.80.0090.00919.39
7.4.70.0100.00716.63
7.4.60.0030.01316.68
7.4.50.0030.00616.39
7.4.40.0090.00816.61
7.4.30.0090.00916.54
7.4.00.0110.00715.06
7.3.330.0000.00613.32
7.3.320.0000.00513.45
7.3.310.0030.00516.36
7.3.300.0000.00716.49
7.3.290.0060.00816.52
7.3.280.0070.01116.52
7.3.270.0120.00817.40
7.3.260.0090.00916.50
7.3.250.0070.01016.61
7.3.240.0090.01316.60
7.3.230.0110.00716.39
7.3.210.0120.00616.66
7.3.200.0030.01519.39
7.3.190.0190.00616.38
7.3.180.0000.01616.48
7.3.170.0030.01516.48
7.3.160.0080.00816.56
7.3.120.0000.01715.07
7.3.110.0090.00914.84
7.3.100.0120.00314.69
7.3.90.0100.00314.65
7.3.80.0100.00715.10
7.3.70.0000.01714.58
7.3.60.0030.00914.66
7.3.50.0090.00914.96
7.3.40.0110.00314.89
7.3.30.0040.00714.97
7.3.20.0060.00916.68
7.3.10.0080.00616.60
7.3.00.0130.00016.64
7.2.330.0100.01416.54
7.2.320.0000.01716.68
7.2.310.0070.01116.51
7.2.300.0060.01016.86
7.2.290.0110.00716.70
7.2.250.0030.01314.94
7.2.240.0000.01815.08
7.2.230.0080.00615.05
7.2.220.0080.00414.75
7.2.210.0060.00814.80
7.2.200.0030.00915.07
7.2.190.0000.01715.11
7.2.180.0090.00315.12
7.2.170.0030.01414.83
7.2.00.0060.01019.35
7.1.330.0000.01315.73
7.1.320.0070.00715.29
7.1.310.0000.01415.61
7.1.300.0070.01115.68
7.1.290.0090.00915.71
7.1.280.0060.00315.69
7.1.270.0000.00815.87
7.1.260.0030.00615.68
7.1.200.0000.00715.46
7.1.100.0000.01218.05
7.1.70.0000.01316.72
7.1.60.0110.01119.11
7.1.50.0100.01016.60
7.1.00.0030.07722.28
7.0.200.0000.00816.70
7.0.140.0000.08022.20
7.0.100.0100.08320.15
7.0.90.0100.07720.00
7.0.80.0070.08020.05
7.0.70.0030.07319.93
7.0.60.0100.07719.99
7.0.50.0030.05720.45
7.0.40.0030.08720.11
7.0.30.0130.07320.06
7.0.20.0070.04719.91
7.0.10.0170.07720.10
7.0.00.0100.08020.14
5.6.280.0030.07021.15
5.6.250.0070.08320.68
5.6.240.0130.08020.67
5.6.230.0030.08020.59
5.6.220.0070.08320.64
5.6.210.0170.06720.64
5.6.200.0100.07720.99
5.6.190.0100.08320.98
5.6.180.0170.06021.10
5.6.170.0100.08721.09
5.6.160.0100.06321.14
5.6.150.0070.08021.04
5.6.140.0130.08021.05
5.6.130.0030.08021.14
5.6.120.0270.07021.05
5.6.110.0130.08021.20
5.6.100.0100.07321.10
5.6.90.0170.04321.14
5.6.80.0100.05020.59
5.6.70.0130.07020.36
5.6.60.0030.05720.43
5.6.50.0100.07720.46
5.6.40.0030.08020.39
5.6.30.0070.07320.45
5.6.20.0130.07020.49
5.6.10.0070.08020.34
5.6.00.0100.07720.33
5.5.380.0130.06720.57
5.5.370.0100.05320.40
5.5.360.0100.07720.41
5.5.350.0100.07720.38
5.5.340.0100.07720.68
5.5.330.0130.08020.84
5.5.320.0100.07720.67
5.5.310.0100.07320.76
5.5.300.0000.05720.96
5.5.290.0130.05720.80
5.5.280.0070.08320.91
5.5.270.0130.07020.86
5.5.260.0070.07320.89
5.5.250.0130.06720.73
5.5.240.0100.06720.19
5.5.230.0030.07020.27
5.5.220.0130.04720.17
5.5.210.0030.05020.24
5.5.200.0130.07320.30
5.5.190.0170.07020.30
5.5.180.0070.08020.25
5.5.160.0170.04320.31
5.5.150.0070.08020.02
5.5.140.0170.07020.11
5.5.130.0070.08720.28
5.5.120.0070.07020.27
5.5.110.0100.07720.20
5.5.100.0070.07720.15
5.5.90.0070.08020.13
5.5.80.0070.04020.16
5.5.70.0030.08019.96
5.5.60.0000.07720.11
5.5.50.0100.07720.09
5.5.40.0100.07720.09
5.5.30.0070.07019.99
5.5.20.0100.07720.17
5.5.10.0100.05720.10
5.5.00.0130.06720.16
5.4.450.0100.07719.36
5.4.440.0130.06719.45
5.4.430.0100.08019.28
5.4.420.0100.07019.29
5.4.410.0030.05019.23
5.4.400.0030.08019.13
5.4.390.0200.06718.86
5.4.380.0070.07719.14
5.4.370.0130.06019.16
5.4.360.0270.06719.17
5.4.350.0100.05718.97
5.4.340.0130.07319.14
5.4.320.0100.08019.14
5.4.310.0130.06719.25
5.4.300.0030.07718.90
5.4.290.0100.07019.14
5.4.280.0100.08019.21
5.4.270.0030.08319.25
5.4.260.0100.06319.05
5.4.250.0030.06019.16
5.4.240.0030.07718.90
5.4.230.0070.07719.04
5.4.220.0130.07318.96
5.4.210.0070.07319.13
5.4.200.0070.07318.89
5.4.190.0070.07019.07
5.4.180.0070.07019.08
5.4.170.0070.05019.05
5.4.160.0070.07318.88
5.4.150.0070.08019.15
5.4.140.0030.07316.44
5.4.130.0070.07316.36
5.4.120.0100.07016.50
5.4.110.0100.07316.55
5.4.100.0100.07016.34
5.4.90.0100.07316.60
5.4.80.0100.05016.52
5.4.70.0070.07016.46
5.4.60.0070.07716.46
5.4.50.0100.06716.50
5.4.40.0030.07716.54
5.4.30.0030.07316.37
5.4.20.0070.06716.39
5.4.10.0030.06716.45
5.4.00.0070.07015.88

preferences:
40.13 ms | 401 KiB | 5 Q