But scripts written in PHP are themselves memory-safe. The problem here isn't in a particular PHP script, but rather in the underlying implementation of the PHP runtime, which was written in a memory-unsafe language.
If that's your standard, then Python isn't a memory-safe language either, since CPython is partially written in C. Same as many other memory-safe languages like Ruby, anything in the .NET ecosystem...
Sure, and that's the problem: if security was taken as seriously as in any other industry then all of the above languages would have been written in SPARK(or its successor, which would likely have happened much before Rust had safety been paramount).