RDV+DIAL chat illimit� dans ta r�g!
no save
Assistance
Achat
News

Forum | programmation
[php] communiquer entre classe et fonctions
otip, le mar. 24 oct. 2006 à 17:52:29
Bonjour,

Je vais essayer d'etre clair.

Je me remets TRES doucement à php.

J'ai fais une page class.php qui contient une classe dont voiçi le code :
<?php
$slash = '/';
if (strstr(PHP_OS, 'Win')) $slash = '\\';
define('PATH_SLASH', $slash);

//$root = getcwd();
//define('DEFAULT_PATH_ALBUMS',$root.PATH_SLASH.'ALBUMS_PHOTOS'.PATH_SLASH);
define('DEFAULT_PATH_ALBUMS','.'.PATH_SLASH.'ALBUMS_PHOTOS'.PATH_SLASH);

class Album{

public $largeur;
public $hauteur;
public $extension;
public $tabl_dossiers = array();
public $tabl_thumbs = array();


function est_image($chemin_fichier) { // PB il faut retourner hauteur et largeur
$types_ok = array ('image/jpeg', 'image/gif', 'image/png');
if (list($this->largeur, $this->hauteur, $type) = getimagesize($chemin_fichier)) {
$type = image_type_to_mime_type($type);
if (in_array($type, $types_ok)) {
$ext = explode("/", $type);
$this->extension = $ext[1];
return true;
}
}
return false;
}
}
?>


Bon dans un autre fichier php, je fais appel à la fonction est_image. PUIS plus loin j'ai une fonction qui utilise des valeur censées venir de la fonction de ma classe, voici le code de cette fonction :


function make_thumb($origin_image,$path_thumb) {
//$album = new Album();
// Calcul du ratio entre la grande image et la miniature
if ($album->largeur <= $album->hauteur) {
$ratio = $album->hauteur / MAX_LONG;
} else {
$ratio = $album->largeur / MAX_LONG;
}
//...


voici l'erreur obtenu :

Warning: Division by zero in /home/photos/public_html/monscript.php on line 61

Warning: Division by zero in /home/photos/public_html/monscript.php on line 62

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/photos/public_html/monscript.php on line 65

Warning: call_user_func(imagecreatefrom) [function.call-user-func]: First argument is expected to be a valid callback in /home/photos/public_html/monscript.php on line 68

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/photos/public_html/monscript.php on line 71

En gros, si je pige bien, il me dit largeur et hauteur valent 0 ou sont vide.

donc il ne récupère aucune valeur.

Comment dois-je faire.

je précise que je fais bien un :

$album = new Album();

mais dans une autre fonction qui appelle make_thum().

Merci pour votre aide.

otip Configuration: php5, debian etch
Version Web
Réalisé par RedShift
no save