Call to undefined function

Résolu
dmk04 Messages postés 206 Date d'inscription samedi 29 octobre 2005 Statut Membre Dernière intervention 7 mars 2012 - 27 déc. 2006 à 10:40
dmk04 Messages postés 206 Date d'inscription samedi 29 octobre 2005 Statut Membre Dernière intervention 7 mars 2012 - 27 déc. 2006 à 13:55
Bonjour,

Le sujet n'est pas très bien choisit, je suis d'accord, mais je n'ai pas trouvé mieux.

Pour entrer dans le vif du sujet, voici mon code (très simplifié, le problème est isolé) :

<?php


Class maClasse
{
 function maFonction()
 {
  echo "C'est ma fonction!
";
 }
 
 function maClasse()
 {
  maFonction();
 }
}

 $objet = new maClasse();
?>

et mon erreur est Fatal error: Call to undefined function: mafonction() ...

Quelqu'un pourrait-il me dire pourquoi mon code ne marche pas, et comment y remédier ?

Merci d'avance
A voir également:

2 réponses

FhX Messages postés 2350 Date d'inscription mercredi 13 octobre 2004 Statut Membre Dernière intervention 18 avril 2015 3
27 déc. 2006 à 13:02
<?php
Class maClasse
{
 function maFonction()
 {
  echo "C'est ma fonction!
";
 }
 
 function maClasse()
 {
  $this->maFonction();
 }
}

Voir :
http://fr3.php.net/manual/fr/language.oop.php
http://fr3.php.net/manual/fr/language.oop5.php
3
dmk04 Messages postés 206 Date d'inscription samedi 29 octobre 2005 Statut Membre Dernière intervention 7 mars 2012
27 déc. 2006 à 13:55
Merci, ça marche.
0
Rejoignez-nous