Jump to content

Recommended Posts

Hi, i am looking for help regarding the eval function in php.

 

The story is, i have a function below in an object call datagrid :

function showSelectorColumn($columnName, $controlName, $valueSeed)
    {
    
        // adds column to the array of columns specified by the user
        $this->showCustomColumn("%dataGrid_selectorColumn%", $columnName);
        
        // unsets any action for this column and blocks any further settings of actions for this column
        $this->unsetActionFunction("%dataGrid_selectorColumn%", true);
        
        // disables sorting for this column
        $this->disableSorting("%dataGrid_selectorColumn%");
        
        // the function that will generate the content for the cell
        $functionString = "
            function _selector(\$data, \$rowData)
            {
                return '
                    <input type=\"checkbox\" style=\"margin:-2px;font-size:0px;\" name=\"".$controlName."[]\" value=\"'.@\$rowData[\"".$valueSeed."\"].'\" class=\"grid-row-selector-checkbox\" onclick=\"if (this.checked == false) {this.parentNode.parentNode.className = this.parentNode.parentNode.id} else {this.parentNode.parentNode.className = \'grid-row-selected\'}\">
                ';
            }
        ";
        
        // registers the function
        eval ($functionString);

}

Now i want to use the _selector function elsewhere in the object.

But as soon as i do "$this->_selector('param1',param2);

i get an error message saying the object is undefined. Can anybody help me with this?

 

Thankz alot

Link to comment
https://forums.phpfreaks.com/topic/51040-eval-function-string-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.