note 38258 rejected from function.eval by pollita
| From: | pollita@php.net | Date: | Sun, 14 Dec 2003 04:57:15 +0000 |
| Subject: | note 38258 rejected from function.eval by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-61925@lists.php.net to get a copy of this message | ||
Note Submitter: mina86@tlen.pl
----
Re: Mark Aufflick (17-Nov-2003 03:49)
Sorry.. it won't work.. Consider such string:
<?php $a = 1; ?>
<?=$a?>
<?php $a = 2; ?>
<?=$a?>
Use rather:
<?php
function eval_html($string) {
$string = preg_replace("/(<\?=)(.*?)\?>/si",
"<?php echo \\1; ?>",$string);
return preg_replace_callback("/(<\?php|<\?)(.*?)\?>/si",
"eval_buffer",$string);
}
?>
------------------
Re: lclkk at urbanvagabond dot net (11-Sep-2003 05:04)
Varible functions might be useful for you, eg:
<?php
class Foo {
function Foo($arg1,$arg2,$arg3) {
echo "I am Foo, I expect 3 arguments...\n";
echo "arg1 = $arg1\n";
echo "arg2 = $arg2\n";
echo "arg3 = $arg3\n\n";
}
}
class Bar {
function Bar($arg1) {
echo "I am Bar, I expect 1 argument...\n";
echo "arg1 = $arg1\n\n";
}
}
$name = 'Foo';
$myFoo = $name(100,'moose',array(1,2,3));
$name = 'Bar';
$myBar = $name(4564);
?>
------------------
Re: G Systemacher (14-May-2003 03:10)
Maybe you should try:
<?php
function set_result_array($fn_request_key = '[DEFAULT]', $fn_result) {
$target_array = &$this->{"result_$fn_request_key"}
if (!is_array($target_array)) { $target_array = array(); }
return array_push($target_array, $fn_result);
}
?>
------------------
Re: mjohnson at onfiber dot com (12-Oct-2002 04:18)
More PHP would be:
<?php
class Processor {
var $_callbacks;
function Processor($cmd) {
$this->_callbacks = array( "add"=>"add"
, "cha"=>"change"
, "del"=>"delete"
, "new"=>"add"
, "mod"=>"change"
, "rem"=>"delete"
);
if (isset($this->_callbacks[$cmd])) {
$proc = $this->_callbacks[$cmd];
$this->$proc();
}
}
function add() { echo "add"; }
function change() { echo "change"; }
function delete() { echo "delete"; }
}
?>
------------------
Re: phoebebright at spamcop dot net (13-Aug-2002 08:05)
This works just fine: $z = ${$array}[$e];
------------------
Re: taq at terra dot com dot br (17-Jul-2002 12:18)
You might use $var = ${"p$i"} or even better: $_POST["p$i"]