convertir du code php stocké dans une table mysql
Bonjour à tous,
j'ai un code (php + javascript) stocké dans un champs de ma table et je souhaite interpréter la partie php.
j'ai essayé avec la fonction eval() mais sans succès.
Voici mon code php qui est stocké dans la base de données :
Code:
1 2 3 4 5 6 7 8 9 10 11
| var quid = <?php echo $quid; ?>;
var options = {
chart: {
// height: 350,
type: bar,
stacked: true,
title: {
text: "<?php echo $questions[$dbid]['name']; ?>"
},
}}; |
Je souhaiterais interpréter que la partie php, y a t'il un moyen ?
j'ai aussi tenter d'utiliser ces deux fonctions mais sans succès :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| function exec_php($php_string) {
return preg_replace_callback(
'/<\?(?:php)?(.*)\?>/m',
'exec_php_embed',
$string
);
}
function exec_php_embed(array $args) {
if (count($args) != 2) {
return '';
}
list(,$code) = $args;
ob_start();
eval($code);
return ob_get_clean();
} |
Merci pour votre aide