-
uso di librerie GD
salve! ho questa righa in php pero non mi funziona ,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
$im = imagecreate(100, 100)
or die("Error al creare ");
$fondo = imagecolorallocate($im, 225, 255, 255); // bianco
header("Content-type: image/png");
imagepng($im);
// imagedestroy($im);
?>
<body>
</body>
</html>
-
non puoi usare quel codice così, dovresti usare file separati e non usarlo come un js
Codice HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<img src="image.php" alt="" />
</body>
</html>
Codice PHP:
<?php
$im = imagecreate(100, 100)
or die("Error al creare ");
$fondo = imagecolorallocate($im, 225, 255, 255); // bianco
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
-
1° "non mi funziona" può voler dire tutto o niente: quando esponi i problemi descrivi dettagliatamente tutte le info utili, ad esempio, come in questo caso, gli eventuali messaggi di errore, i risultati inattesi, etc.
2° usa gli appositi tag quando posti del codice
3° la pagina in questione deve avere l'estensione .php
4° per usare gli header non devi avere nessun tipo di output html prima di esso, quindi la prima riga del file deve contenere <?php (senza spazi bianchi prima)
Ciao!