if (CRM_Core_DAO::checkFieldExists('contact', 'email')) { // Perform operations here if the field exists } else { // Handle error or exception here if the field does not exist }
$field_id = 123; // Custom field ID if (CRM_Core_DAO::checkFieldExists('custom_field', 'id', $field_id)) { // Perform operations here if the field exists } else { // Handle error or exception here if the field does not exist }This function is part of the civicrm-core package library, which is the main library that contains all the functions, classes, and methods needed to develop and maintain CRM applications using PHP.