如何将常量作为变量传递?

aI want to set up a generic wrapper class method for setting options in curl requests, like so;

curl_setopt($curl_handles[$i], CURLOPT_RETURNTRANSFER, true); 

However, I want to be able to pass the constant via the parameter in my method, so something like;

protected function set_option($i, $OPTION)
{

    curl_setopt($curl_handles[$i], $OPTION, true);  

} 

Is this even possible? I haven't tried this, but I get the feeling this won't work. Can a name of constant be stored in a variable like this?

Are you asking how to pass a constant into a method parameter? What you have should work just fine.

protected function set_option($i, $OPTION)
{
    curl_setopt($curl_handles[$i], $OPTION, true);  
}

set_option(1, CURLOPT_RETURNTRANSFER);