'how to run sparql query against local rdf file in php

I have wrote some SPARQL queries against DBPedia's SPARQL endpoint, because sometimes this endpoint is not available. I have downloaded some RDF files (e.g. counties.rdf).

How can I run my queries against the RDF file? I tried replacing the address of the endpoint with my local path but it does not work.

Example:

 var url = "http://dbpedia.org/sparql";   == http://localhost/myfile/india.rdf
 var query = "
     PREFIX dbpedia2: <http://dbpedia.org/resource/>
     PREFIX ABs: <http://dbpedia.org/ontology/>
     SELECT ?capital
     WHERE {
         ?s dbpedia2:India\"@en;\ abs:capital ?capital\ 
     }";


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source