-
-
Save parzibyte/9acd901b2cec4f2f9574e96399e4d205 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Ejemplo 6 para generar códigos de barras | |
* con PHP | |
* | |
* Generar código y mostrar dependiendo de parámetro GET | |
* | |
* @author parzibyte | |
*/ | |
# Si no hay parámetro, salir | |
# https://parzibyte.me/blog/2018/08/09/isset-vs-empty-en-php/ | |
if(empty($_GET["texto"])) exit("No proporcionaste el texto en la URL"); | |
# Incluimos el autoload | |
require_once "vendor/autoload.php"; | |
# Indicamos que usaremos el namespace de BarcodeGeneratorPNG | |
use Picqer\Barcode\BarcodeGeneratorPNG; | |
# Crear generador | |
$generador = new BarcodeGeneratorPNG(); | |
# Ajustes | |
$texto = $_GET["texto"]; | |
$tipo = $generador::TYPE_CODE_128; | |
$imagen = $generador->getBarcode($texto, $tipo); | |
header("Content-type: image/png"); | |
echo $imagen; | |
# No imprimas nada después de esto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment