Skip to content

Instantly share code, notes, and snippets.

@Thinkscape
Created May 2, 2013 11:36
Show Gist options
  • Select an option

  • Save Thinkscape/5501645 to your computer and use it in GitHub Desktop.

Select an option

Save Thinkscape/5501645 to your computer and use it in GitHub Desktop.
<?php
error_reporting(E_ALL & ~ E_NOTICE);
ini_set('display_errors',1);
require_once 'autoload_register.php';
$content = 'foobar';
if(isset($_GET['genimg']) || PHP_SAPI == 'cli'){
header('Content-Type: image/svg+xml');
$renderer = new \BaconQrCode\Renderer\Image\Svg();
$writer = new \BaconQrCode\Writer($renderer);
echo $writer->writeString($content);
exit;
}else{
$renderer = new \BaconQrCode\Renderer\Text\Plain();
$renderer2 = new \BaconQrCode\Renderer\Text\Html();
$writer = new \BaconQrCode\Writer($renderer);
$writer2 = new \BaconQrCode\Writer($renderer2);
}
?>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>
<table border="1">
<thead>
<tr>
<td>Svg:</td>
<td>Text (courier new):</td>
<td>HTML (monospace):</td>
</tr>
</thead>
<tr>
<td>
<img src="?genimg=1" width="200" height="200"/>
</td>
<td>
<pre style="font-family: 'courier new'; font-size: 12px; line-height: 0.7em; "><?php echo $writer->writeString($content);?></pre>
</td>
<td>
<?php echo $writer2->writeString($content);?>
</td>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment