Patch using method below or if you don't want to patch a core file, see this Magento extension that does the same thing but correctly overrides the core file:
https://github.com/MageMechanic/PhpSeven
# run in magento root directory
# one-liner to apply patch using wget
wget -qO- 'https://gist.githubusercontent.com/MageMechanic/66449504110fbbd96214/raw/php7_magento_1_9_core.patch' | patch -p0
# one-liner to apply patch using curl