So how would a person be able to know if the script they wrote is good. Is there something like a validator for php as there is for html?
There are syntax checkers built into most decent code editors that will tell you if you have made relatively simple errors in using the language, but that's the easy part. That won't tell you whether the program does what you want it to do, or just as importantly, that it does not do things you don't want it to do. That's where various types of testing come into play (unit tests, integration tests, system tests, load tests, performance tests, and so forth).
But then that's the same with HTML: a validator will tell you if you have well-formed HTML, but it won't tell you if the content makes sense, if all the links actually link to something, how the page looks in different sized displays/devices, how well Google will understand what it's about, etc.
Ultimately, HTML is easy, it's just a text mark-up language with no program flow control, data processing, and so forth. Using a programming language to write software is another kettle of fish: it by no means has to be rocket science for most web programming, but there is a lot more to it than just learning the syntax. I'm not trying to scare you off, just help you realize it's a different sort of thing that will have a much higher learning curve. But if you found learning HTML and CSS to be fairly easy, then you probably have a logical mind, which is a good starting place. Just be aware that there is a lot more to learn to write non-trivial software, but it's also, for me anyway, a lot more interesting and rewarding.