Alternative to eval()

I have a widget in Wordpress which uses eval() in the code but this is switched off on the server and so can’t be used. I was wondering if anyone could give me some assistance with respect to changing the following code so that it doens’t use eval. I’m just a beginner but am willing to learn so any help would be appreciated.

function widget( $args, $instance ) {
	$title = apply_filters( 'widget_title', empty($instance['title']) ? '' : $instance['title'], $instance );
	$text = apply_filters( 'widget_execphp', $instance['text'], $instance );
	echo $before_widget;
	if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 
		$text = ob_get_contents();
		<div class="execphpwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
	echo $after_widget;

You can’t “switch off” a function. What error is it giving you?

You absolutely can. Check your php.ini file, you will see this:

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
disable_functions =

OP, I don’t know much about wordpress other than it is HIGHLY insecure and easily hacked. The use of eval() is a likely cause. Sorry I don’t have an answer for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service