Bonjour à tous,
j'ai trouvé un code ici : https://geekpad.ca/blog/post/simple-...sing-singleton
super intérressant qui permet de faire un fichier de configuration pour l'utiliser dans mon programme php :
je l'ai donc implémenter dans mon programme, mais je me retrouve avec un warning suivant, que je ne sais pas arranger :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 PHP Deprecated: Non-static method SimpleConfig::setFile() should not be called statically in /var/www/html/dp on line 35 Deprecated: Non-static method SimpleConfig::setFile() should not be called statically in /var/www/html/demoFiline 35
voici comment je l'utilise dans mon code :
est ce que quelqu'un aurais une piste svp sur ce warning
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 /* Far far away into some of your brilliant code */ SimpleConfig::setFile('./config/config.php'); $config = SimpleConfig::getInstance();
merci par avance
Edit 1:
j'ai essayé de déclarer mon instance comme ceci :
mais c'est pire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 $configClass = new SimpleConfig(); $configClass->setFile('./config/config.php'); $config = $configClass->getConfig();
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 PHP Fatal error: Uncaught Error: Call to protected SimpleConfig::__construct() from invalid context in /var/www/html/ya.php:38 Stack trace: #0 {main} thrown in /var/www/html/ya.php on line 38 Fatal error: Uncaught Error: Call to protected SimpleConfig::__construct() from invalid context in /var/www/html/ya.php:38 Stack trace: #0 {main}
Partager