I have not really used PHP and RDF together. Instead, I did it using Python. There we had a library called "rdflib" which can be used to load an RDF in an object, and then execute SPARQL queries on it.
I think there is something like this in PHP. After some "googling", I came by easyrdf which seems to be quite similar. Their documentation provides a bunch of examples in which I see something like "Making a SPARQL SELECT query". Hope it helps
Edit note: This example does not work for a local file. EasyRDF requires an http / https endpoint.