OK, let's use an example. You have a search page that takes a GET parameter for the search query.
http://example.com?search=test+search
On your search page, you do something like this.
<p>your search results for "{search}":</p>
This is vulnerable to reflected XSS. The following query:
http://example.com?search=<script>alert(1);</script>
would result in the following HTML:
<p>your search results for "<script>alert(1);</script>":</p>
Obviously, that's not good, as it will execute the script (well, the XSS Auditor will probably block it, but we don't depend on that). The first thing we can do to help prevent XSS is to escape this string since it is un-trusted and comes from the client.
<p>your search results for "{HTML.Escape(search)}":</p>
The syntax for this, of course, depends on your server-side language. In general, you are looking for HTMLEncode/Escape/etc. I'm sure someone can point you to a function or library for doing this in PHP.
Now that we escape the string, our output would look like this:
<p>your search results for "<script>alert(1)</script>":</p>
That will show up as <
in the browser, but the source will be encoded (<
).
This is the general overview of preventing most XSS. Manually escaping every input can be a little risky, cause you might forget one. So you want to use some kind of templating system. There are different things you do for HTML attributes/javascript strings/html entities, etc.
Google has a great introductory resource for this:
https://www.google.com/about/appsecurity/learning/xss/#PreventingXSS