Getting category id of current post

<?php
$categories = get_the_category( $post->ID );
$categories =     (array) $categories[‘0’];
$catid=$categories[‘term_id’]; ?>