Sony announced today in a comprehensive Q&A posted to the PlayStation Blog that PlayStation 3 and PlayStation 4 users can play together online if developers choose to support it for their games.
"The functionality is technically possible and some developers may choose to support it for their titles," the Q&A read. To date, there have been no games announced that support this functionality, although massively-multiplayer online games like Final Fantasy 14: A Realm Reborn and DC Universe Online could potentially benefit from having cross-platform play.
Competitor Microsoft announced earlier this year that the Xbox One and Xbox 360 will not support cross-platform play. A Microsoft spokesperson told Polygon that "because of the different architecture of the systems, [cross-platform play] is not possible. Your Xbox Live account on 360 will carry over to Xbox One. The same account will work on both platforms. Multiplayer won't."
UPDATE: When asked via Twitter if there are any games that are currently in development that will support PS3 and PS4 users playing together, the head of Sony Computer Entertainment Worldwide Studios Shuhei Yoshida said Helldivers is one of them. Helldivers is coming to PS3, PS4 and PS Vita, will be cross-buy compatible across all three and will also feature cross-play between the PS4 and PS Vita.