Voici le script : Niveau débutant.
Ce script n'aura de but que de charger les informations d'un objet cible.
- Code: Tout sélectionner
<?php
function cibleInfos($url)
{
// ..
// .. Variable de mise en page ..
// ..
$br = "<br />";
// ..
// .. Variable essentielle
// .. $url est la cible à manipuler
// .. $informations l'objet Array à interroger ..
// ..
$informations = getimagesize($url);
// ..
// .. Le type affecté à la variable avec la fonction getimagesize() ..
// .. est un toujours un array : $informations est-il de type Array ? ..
// ..
if (is_array($informations))
{
// .. On vérifie le type d'objet ..
// ..
echo "Le type d'objet \$informations est un : " . $informations . $br;
// ..
// .. Les différentes informations sur l'image cibler ..
// ..
print_r($informations); echo $br.$br;
// ..
// .. On affiche les informations de l'image ..
// ..
echo "Index [0] - Largeur (int) : " . $informations[0] . $br;
echo "Index [1] - Hauteur (int) : " . $informations[1] . $br;
echo "Index [2] - Type Image (int) : " . $informations[2] . $br;
echo "Index [3] - Attributs HTML (string) : " . $informations[3] . $br;
echo "Index [bits] - Bits (int) : " . $informations['bits'] . $br;
echo "Index [channels] - Cannaux (int) : " . $informations['channels'] . $br;
echo "Index [mime] - Type mime (string) : " . $informations['mime'] . $br;
}
else
{
echo "Le type d'objet n'est pas un array.";
}
}
// ..
// .. Appelle de la fonction ..
// ..
cibleInfos("images/Signature_01a.jpg");
?>
Voici les résultats d'affichage :
Le type d'objet $informations est un : Array
Array ( [0] => 615 [1] => 145 [2] => 2 [3] => width="615" height="145" [bits] => 8 [channels] => 3 [mime] => image/jpeg )
Index [0] - Largeur (int) : 615
Index [1] - Hauteur (int) : 145
Index [2] - Type Image (int) : 2
Index [3] - Attributs HTML (string) : width="615" height="145"
Index [bits] - Bits (int) : 8
Index [channels] - Cannaux (int) : 3
Index [mime] - Type mime (string) : image/jpeg
url d'étude : http://ca3.php.net/manual/fr/function.getimagesize.php
++







