Have you actually set up a local server? You'll need this to run PHP scripts. For a newbie I'd recommend WampServer since it's really easy and handles all the complexity of installing a server. Once installed and running, try http://localhost/ in your web browser.
Based on your comment though, I think the problem is that the sample code on the page you posted won't work on their own, you'd need to combine them with other things. For example the first one references a variable $user_input
which you'd replace with a variable taken from user input (eg a form) on your site.
I suggest finding some tutorials online (or buy a book) and walk through various proper examples to familiarise yourself with PHP.