How to use variables in a PHP evaluation in a rule? I created a rule with the actions "Provide a variable: mynumber" and "Grant points to a user". I'd like to evaluate the points with PHP, using "mynumber". For some reason, I can't use $mynumber, although that is possible in the PHP evalution of the sections 'Operation' and 'Description'. As the replacement pattern [mynumber] is available, I tried to use it in my code with and without the square brackets, but in both cases, I get the error:


  Notice: Use of undefined constant mynumber - assumed 'mynumber' in
  eval() (line 1 of
  C:\wamp\www\mysite\sites\all\modules\rules\modules\php.eval.inc(146) :
  eval()'d code).


Is this a missing feature, a bug in the Rules module or did I do something wrong?
You can achieve this,  use variable module and define variable which you want use in rule.

To define a variable you need to write custom module , which will contain following function

function My_module_variable_info() {
  $variables['rainbow_count'] = array(
  // 'name' isn't really necessary, as it will get populated from the key of this array above.
 'name' =&gt; 'rainbow_count',
 'title' =&gt; t('Number of Rainbows'),
 'type' =&gt; 'number',
 'group' =&gt; 'UserPoints Config',
 'token' =&gt; TRUE,
'default' =&gt; 0,
'description' =&gt; t('Specify the number of rainbows.')
); 

}


Set value for variable which you want use in rule through : 

configuration&gt;&gt;variables&gt;&gt;modules&gt;&gt;My_module_...

Now go to rules >action> grant points to a user > Points:

Set data type =current-user:uid  and put return variable_get('rainbow_count'); code in PHP evaluation.

This solution worked for me,hope will help you also.