print_r或echo变量以查看id等于的内容

enter image description here

I know by looking in the database that CL1 is equal to 6. How would i print_r or echo out this statement below. Also is there a way to just echo it out in terminal? I know if i change CL1 to Taxable Goods it would echo out a different id.. 2. I'm just not sure how to actually do it..

$product = Mage::getModel('catalog/product'); // Might not need this if product is already loaded
$attribute = $product->getResource()->getAttribute('tax_class_id');
if ($attribute->usesSource()) {
    $optionId = $attribute->getSource()->getOptionId('CL1');
}

Do i wrap the whole statement or just try to echo out the $optionId variable?

Any help would be greatly appreciated.

Mostly for printing purpose you better you var_export() please check this link.

to log it in the console: (edited)

echo("<script>console.log('".$optionId."');</script>");

print it out:

print($optionId); //or
echo($optionId);