In general, you cannot play PS3 games on PS4 or PS5 as the PS4 did not have backward compatibility. However, there are some exceptions to the rule. Up until recently, there was a catalog of PS3 games that were available on PS Now, and with the move to PS Plus Extra, the PS player base can now play a different selection of PS3 games via streaming. Then, of course, some of the games listed are available in remastered collections and remakes, so there is also that option if you want a more refined, modern version of the suggested titles above.