Depending on what you're going to display or hide, this sounds like cloaking, which google disapproves of. Strongly. As in they'll remove your site from their results if they think you're doing it.
Anyway, you just have to check if the text "googlebot" is in $_SERVER['HTTP_USER_AGENT']. (If you're not sure how to test for the presence of a string check out strpos.)