I have already covered a topic on How to add adsense code to wordpress sidebar without any plugin. Though wordpress sidebar widget allow us to add HTML and Text code only. It does not support php code.
Though if you want to show some widget which use php code, you can use Samsarin PHP widget plugin, which add an option to add PHP widget in your sidebar.
Download the Samsarin PHP widget wordpress plugin from author homepage and upload it on your plugin folder.
Activate the plugin, navigate to Appearance > Widget
And select Samsarin widget .
Add php code and click on save.
The plugin seems to be very handy for including php code for recent posts, popular posts.
There are other plugins which will also amuse you
Feed subscription reminder for wordpress
Get Free Blogging updates in your Email