Erm I dunno if you realised or not but converting the first code to the other would be pointless - they're the same
As for the get_magic_quotes_gpc(), I'd be interested to know if that function will still exist. I would think it would for backwards compatibility but I've not the vaguest idea where to look to find out. Fou is much more into the latest PHP developments than most so he will be certain to know.
Whoops just realised the difference, you're using set_magic_quotes_runtime(0) in the first code - doh!
Best I can tell, get_magic_quotes_gpc will persist. At least for now. set_magic_quotes_runtime is gone.
So ultimately, that is a pain.
You do not require it if you do not share your code AND you are on 5.4+. If you do share your code, you still require it, and then some:
Well we did try Fou-Lu, but unfortunately even with the if function exists i still get the deprecated message in my log files. And i dont like messages in my log files lol.. So i just removed the 'set_magic_quotes_runtime' all together. Good try though
That will happen anyways, so long as you are calling it. There isn't a way other than reflection to determine if it is deprecated (reflection can tell you), so as soon as you call it it will trigger an E_DEPRECATED level error. And currently you would need to call it if you are on < 5.4. You can also scan for get_magic_quotes_runtime first, which will return false in > 5.4 or when disabled. That could be used in conjunction with function_exists or reflection to see if it should even bother calling set_magic_quotes_runtime (which in the past never mattered since you'd always want to disable it).
You can disable that by setting the E_DEPRECATED level off (ie: E_ALL ^ E_DEPRECATED), but I'm trying to recall if it will still log it regardless. You can try to set that in the php.ini to see if that removes it from logs. Personally I prefer all errors in log regardless of what they are.
Yeah, if you do that you'll always end up with E_ALL after the function call regardless of what the program has set for its error reporting.
If you are intent on doing so than you should capture the existing reporting first:
Mask it after setting it, yeah that should disable it even if it already is.
Oh yeah and another though. You can try simply adding the suppressor to the set_magic_quotes_runtime. I don't know for sure if that will work with E_DEPRECATED, and I don't know for sure if it doesn't log it anyway. You can give that a try and see the result.
I did find that the supressor does not work in that fashion but good news The above works. I added it before the set magic quotes call and then to test it, i ran a few pages that call that function with E_ALL reporting on those pages and nothing came up..