IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Utilisation de Runkit_Sandbox


Sujet :

Langage PHP

  1. #21
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    bizarre essaye avec ./configure --enable=rename, sinon crée le dossier module
    sinon je testerai chez moi ce soir, j'ai pas essayé sous Unix

  2. #22
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Alors, déjà hier, j'ai essayé avec ou sans le dossier modules, sans succès.

    Avec ./configure --enable=rename ou ./configure --enable-rename:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    configure: WARNING: unrecognized options: --enable-rename
    Merci pour ton dévouement et ta patience, en tous cas...

  3. #23
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    J'ai pitêt une piste...

    Bon, je ne connais rien à ce langage j'ai juste comparé le code de ton config.m4 à la description trouvée ici.

    En lisant le tien, j'ai vu que quasi tout est commenté (notamment, les sections qui permettent de l'activer, comme ton If, qui ne doit pas être là pour rien, j'imagine):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    dnl $Id$
    dnl config.m4 for extension rename
     
    dnl Comments in this file start with the string 'dnl'.
    dnl Remove where necessary. This file will not work
    dnl without editing.
     
    dnl If your extension references something external, use with:
     
    dnl PHP_ARG_WITH(rename, for rename support,
    dnl Make sure that the comment is aligned:
    dnl [  --with-rename             Include rename support])
     
    dnl Otherwise use enable:
     
    dnl PHP_ARG_ENABLE(rename, whether to enable rename support,
    dnl Make sure that the comment is aligned:
    dnl [  --enable-rename           Enable rename support])
     
    if test "$PHP_RENAME" != "no"; then
      dnl Write more examples of tests here...
     
      dnl # --with-rename -> check with-path
      dnl SEARCH_PATH="/usr/local /usr"     # you might want to change this
      dnl SEARCH_FOR="/include/rename.h"  # you most likely want to change this
      dnl if test -r $PHP_RENAME/$SEARCH_FOR; then # path given as parameter
      dnl   RENAME_DIR=$PHP_RENAME
      dnl else # search default path list
      dnl   AC_MSG_CHECKING([for rename files in default path])
      dnl   for i in $SEARCH_PATH ; do
      dnl     if test -r $i/$SEARCH_FOR; then
      dnl       RENAME_DIR=$i
      dnl       AC_MSG_RESULT(found in $i)
      dnl     fi
      dnl   done
      dnl fi
      dnl
      dnl if test -z "$RENAME_DIR"; then
      dnl   AC_MSG_RESULT([not found])
      dnl   AC_MSG_ERROR([Please reinstall the rename distribution])
      dnl fi
     
      dnl # --with-rename -> add include path
      dnl PHP_ADD_INCLUDE($RENAME_DIR/include)
     
      dnl # --with-rename -> check for lib and symbol presence
      dnl LIBNAME=rename # you may want to change this
      dnl LIBSYMBOL=rename # you most likely want to change this 
     
      dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
      dnl [
      dnl   PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $RENAME_DIR/lib, RENAME_SHARED_LIBADD)
      dnl   AC_DEFINE(HAVE_RENAMELIB,1,[ ])
      dnl ],[
      dnl   AC_MSG_ERROR([wrong rename lib version or lib not found])
      dnl ],[
      dnl   -L$RENAME_DIR/lib -lm
      dnl ])
      dnl
      dnl PHP_SUBST(RENAME_SHARED_LIBADD)
     
      PHP_NEW_EXTENSION(rename, rename.c, $ext_shared)
    fi

  4. #24
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    c'est le m4 par defaut quand on crée une extension

  5. #25
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Ben, comme ./configure --enable-rename retourne une erreur, je me disais que c'était pitêt dû au fait qu'il est commenté dans le .m4

  6. #26
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    En remplaçant cette partie :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    dnl PHP_ARG_ENABLE(rename, whether to enable rename support,
    dnl Make sure that the comment is aligned:
    dnl [  --enable-rename           Enable rename support])
    Par :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    PHP_ARG_ENABLE(rename, whether to enable rename support,
    [  --enable-rename           Enable rename support])
    Je n'ai plus d'erreur liée au ./configure --enable-rename mais une nouvelle erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    /home/lcf/common_vm/php_rename/rename.c:23: error: ‘PHP_FE_END’ undeclared here (not in a function)
    make: *** [rename.lo] Erreur 1

    Pour tester, j'ai donc supprimé ce PHP_FE_END (puisque non-déclaré) et, miracle, l'installation se poursuit bien.

    Seul hic, c'est que, côté PHP, la fonction function_rename ne semble pas exister, ce PHP_FE_END servait sûrement à quelque chose.

    'fin, voilà, pitêt que ça t'aidera à identifier ce qui ne va pas.


    EDIT : Je l'ai remplacé par {NULL,NULL,NULL}, selon une explication trouvée ici :

    http://serverfault.com/questions/317...able-extension

    Mais la fonction ne semble toujours pas exister.

  7. #27
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    Alors : le m4

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    dnl config.m4 for extension rename
     
    PHP_ARG_ENABLE(rename, whether to enable rename support,
    [  --enable-rename           Enable rename support])
     
    if test "$PHP_RENAME" != "no"; then
      PHP_NEW_EXTENSION(rename, rename.c, $ext_shared)
    fi
    et a la place du tu mets

  8. #28
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    As-tu vu mon edit?

  9. #29
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    non j'ai pas vu,

    regarde ton php.ini voir si l'extension est bien ajouter

  10. #30
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Ah, oui, comment n'y ai-je pensé?

    Un tout, tout grand merci, ça marche parfaitement.

  11. #31
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    Citation Envoyé par Lcf.vs Voir le message
    Ah, oui, comment n'y ai-je pensé?

    Un tout, tout grand merci, ça marche parfaitement.
    cool

  12. #32
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Je vais enfin pouvoir me remettre à mon dev.


  13. #33
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Bonjour,

    Dis, excuse-moi mais il manque un léger détail auquel je n'ai pas pensé.

    Crois-tu qu'il serait possible de faire en sorte que function_rename() puisse aussi nommer une fonction anonyme (dans le même espace que les autres fonctions, donc accessibles de partout), stp?

    Schématiquement, ça donnerait quelque chose comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    function function_rename(String $old_name, String $new_name){
          // On renomme la fonction
    }
    function function_rename(Function $function, String $new_name){
          if(!function_exists($function)){
                 // On nomme la fonction
          }
    }
    Après, promis, je ne t'ennuie plus. Et, si tu ne veux pas, ben, j'comprendrais, t'en as vraiment déjà fait beaucoup...

  14. #34
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    une Closure ?

  15. #35
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    essaye avec ça

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    #ifdef HAVE_CONFIG_H
    #include "config.h"
    #endif
     
    #include "php.h"
    #include "php_ini.h"
    #include "zend_closures.h"
    #include "ext/standard/info.h"
    #include "php_rename.h"
     
    static int le_rename;
     
    ZEND_BEGIN_ARG_INFO_EX(arginfo_function_rename, 0, 0, 2)
    	ZEND_ARG_INFO(0, orig_func)
    	ZEND_ARG_INFO(0, new_func)
    ZEND_END_ARG_INFO()
     
    /* {{{ rename_functions[]
     *
     * Every user visible function must have an entry in rename_functions[].
     */
    const zend_function_entry rename_functions[] = {
    	PHP_FE(function_rename, arginfo_function_rename)
    	{NULL, NULL, NULL}
    };
    /* }}} */
     
    /* {{{ rename_module_entry
     */
    zend_module_entry rename_module_entry = {
    #if ZEND_MODULE_API_NO >= 20010901
    	STANDARD_MODULE_HEADER,
    #endif
    	"rename",
    	rename_functions,
    	PHP_MINIT(rename),
    	PHP_MSHUTDOWN(rename),
    	NULL,
    	NULL,
    	PHP_MINFO(rename),
    #if ZEND_MODULE_API_NO >= 20010901
    	"0.1",
    #endif
    	STANDARD_MODULE_PROPERTIES
    };
    /* }}} */
     
    #ifdef COMPILE_DL_RENAME
    ZEND_GET_MODULE(rename)
    #endif
     
    /* {{{ PHP_MINIT_FUNCTION
     */
    PHP_MINIT_FUNCTION(rename)
    {
    	return SUCCESS;
    }
    /* }}} */
     
    /* {{{ PHP_MSHUTDOWN_FUNCTION
     */
    PHP_MSHUTDOWN_FUNCTION(rename)
    {
    	return SUCCESS;
    }
    /* }}} */
     
    /* {{{ PHP_RINIT_FUNCTION
    */
    PHP_RINIT_FUNCTION(comuto)
    {
    	return SUCCESS;
    }
    /* }}} */
     
    /* {{{ PHP_RSHUTDOWN_FUNCTION
    */
    PHP_RSHUTDOWN_FUNCTION(comuto)
    {
    	return SUCCESS;
    }
     
    /* {{{ PHP_MINFO_FUNCTION
     */
    PHP_MINFO_FUNCTION(rename)
    {
    	php_info_print_table_start();
    	php_info_print_table_header(2, "rename support", "enabled");
    	php_info_print_table_end();
    }
    /* }}} */
     
    /* {{{ proto string function_rename(string orig_func, string new_func)
    */
    PHP_FUNCTION(function_rename)
    {
    	char *new_func;
    	zval *orig_func;
    	int  new_func_len;
    	zend_function *func;
     
    	if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &orig_func, &new_func, &new_func_len) == FAILURE) {
    		return;
    	}
     
    	if(zend_hash_exists(EG(function_table), new_func, new_func_len + 1)) {
    		zend_error(E_WARNING, "%s() already exists", new_func);
    		RETURN_FALSE;
    	}
     
    	if (Z_TYPE_P(orig_func) == IS_OBJECT) {
    		if (instanceof_function(Z_OBJCE_P(orig_func), zend_ce_closure TSRMLS_CC)) {
    			func = (zend_function*) zend_get_closure_method_def(orig_func TSRMLS_CC);
     
    			if(zend_hash_add(EG(function_table), new_func, new_func_len + 1, func, sizeof(zend_function), NULL) == FAILURE) {
    				zend_error(E_WARNING, "cannot add %s()", func);
    				RETURN_FALSE;
    			}
     
    			RETURN_TRUE;
    		}
     
    		RETURN_FALSE;
    	}
     
    	if (Z_TYPE_P(orig_func) == IS_STRING) {
    		if(zend_hash_find(EG(function_table), Z_STRVAL_P(orig_func), Z_STRLEN_P(orig_func) + 1, (void **) &func) == FAILURE) {
    			zend_error(E_WARNING, "cannot find %s()", Z_STRVAL_P(orig_func));
    			RETURN_FALSE;
    		}
     
    		if(zend_hash_add(EG(function_table), new_func, new_func_len + 1, func, sizeof(zend_function), NULL) == FAILURE) {
    			zend_error(E_WARNING, "cannot rename %s()", func);
    			RETURN_FALSE;
    		}
     
    		if(zend_hash_del(EG(function_table), Z_STRVAL_P(orig_func), Z_STRLEN_P(orig_func) + 1) == FAILURE) {
    			zend_error(E_WARNING, "cannot rename %s()", Z_STRVAL_P(orig_func));
    			RETURN_FALSE;
    		}
     
    		RETURN_TRUE;
    	}
     
    	RETURN_FALSE;
    }
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    $test = function() {
        echo 'hi';
    };
     
    var_dump(function_rename($test, 'test'));
    echo test();
     
    var_dump(function_rename('strtolower', 'lower'));
    echo lower('TEST');

  16. #36
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Désolé, ayant bossé toute la journée d'hier et toute la nuit, fallait que je me repose un peu...

    Alors, je te remercie, c'est presque parfait.

    Ce code (la finalité):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <?php
    	//require_once 'FunctionManager.class.php';
    	class FunctionManager{
    		private static $functions=array();
    		public static function rename($old,$new){
    			$functions[$old]=$new;
    			function_rename($old,$new);
    			function_rename(function(){
    				FunctionManager::exec(__FUNCTION__,func_get_args());
    			},$old);
    		}
    		public static function exec($name,$args){
    			return call_user_func_array($name,$args);
    		}
    	}
    	FunctionManager::rename('str_replace','testabc');
    	str_replace('-','','abc-def');
    ?>
    Me renvoie :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '{closure}' not found or invalid function name in /home/lcf/Desktop/www/index.php on line 13

  17. #37
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    J'ai aussi testé avec create_function():
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    <?php
    	//require_once 'FunctionManager.class.php';
    	class FunctionManager{
    		private static $functions=array();
    		public static function rename($old,$new){
    			$functions[$old]=$new;
    			function_rename($old,$new);
    			function_rename(create_function('','return FunctionManager::exec('.$old.',func_get_args());'),$old);
    		}
    		public static function exec($name,$args){
    			return call_user_func_array($name,$args);
    		}
    	}
    	FunctionManager::rename('str_replace','testabc');
    	str_replace('-','','abc-def');
    ?>
    Renvoie :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Fatal error: Class 'ǘAtionManager' not found in /home/lcf/Desktop/www/index.php(8) : runtime-created function on line 1

  18. #38
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Aïe, il y a pire!

    Ta nouvelle version modifie définitivement mon PHP, à présent, sans même déclarer mon FunctionManager, si je fais uniquement :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <?php
    	str_replace('-','','abc-def');
    ?>
    PHP me dit que str_replace() n'existe pas.

  19. #39
    Expert éminent sénior

    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    7 920
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 7 920
    Points : 10 726
    Points
    10 726
    Par défaut
    ouai j'ai eu le même problème je vais voir pourquoi ça reviens pas a zéro

  20. #40
    Membre éclairé

    Femme Profil pro
    Experte JS / Conseillère en best practices / Chercheuse en programmation
    Inscrit en
    Octobre 2007
    Messages
    741
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : Experte JS / Conseillère en best practices / Chercheuse en programmation
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Octobre 2007
    Messages : 741
    Points : 808
    Points
    808
    Par défaut
    Bonjour,

    Alors, j'ai fait pas mal de tests et, en redémarrant Apache, PHP revient à la normale et, ce, jusqu'à un nombre variable d'appels à function_rename() (comme si cela lançait une boucle interne qui finit par planter).

    Cette possibilité de récupérer un PHP quasiment sain m'a quand même permis de produire un code 100% fonctionnel, avec ta première version corrigée ensemble, pour illustrer le résultat recherché :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    <?php
    	class CallStandard{
    		private static $functions=array();
    		private static function generate(){
    			$chars=str_shuffle('abcdefghijklmnopqrstuvwxyz');
    			$string='';
    			$length=mt_rand(25,75);
    			for($i=0;$i<$length;$i++){
    				$string.=$chars[mt_rand(0,strlen($chars)-1)];
    			}
    			return $string;
    		}
    		public static function addConstraint($old_name,$constraint){
    			if(!isset(self::$functions[$old_name])){
    				while(function_exists($new_name=self::generate()));
    				self::$functions[$old_name]=array('name'=>$new_name,'constraints'=>array($constraint));
    				function_rename($old_name,$new_name);
    				eval('function '.$old_name.'(){return '.__CLASS__.'::call("'.$old_name.'",func_get_args());}');
    			}
    			else{
    				array_push(self::$functions[$old_name]['constraints'],$constraint);
    			}
    		}
    		public static function call($name,$args){
    			if(isset(self::$functions[$name])){
    				$i=-1;
    				while(@call_user_func_array(self::$functions[$name]['constraints'][++$i],func_get_args()));
    				if($i==count(self::$functions[$name]['constraints'])){
    					return call_user_func_array(self::$functions[$name]['name'],$args);
    				}
    			}
    			throw new RuntimeException('Call to undefined function '.$name);
    		}
    	}
    	// Ajout des contraintes, si l'une d'elle retourne false l'appel ne peut se faire
    	CallStandard::addConstraint('str_replace',function(){return true;});
    	CallStandard::addConstraint('str_replace',function(){return true;});
    	CallStandard::addConstraint('str_replace',function(){return true;});
    	echo str_replace('-','','abc-def');
    ?>
    Le seul "hic", c'est la nécessité de passer par eval() qui ne fait pas très propre (mais qui devrait pouvoir être remplacé par function_rename()).

    Sinon, pourquoi le renommage des fonctions n'accepte-il les tout les caractères possibles? ([a-zA-Z0-9_] contre, actuellement, [a-z])

Discussions similaires

  1. utiliser les tag [MFC] [Win32] [.NET] [C++/CLI]
    Par hiko-seijuro dans le forum Visual C++
    Réponses: 8
    Dernier message: 08/06/2005, 15h57
  2. Réponses: 4
    Dernier message: 05/06/2002, 14h35
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 12h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 16h01
  5. Réponses: 2
    Dernier message: 20/03/2002, 23h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo