How to put a website in "Development Mode" ?

I have launched my website. How to update and test the source code in production?
What is the best way to test your modified website when your old website is already in production? Is there a option of putting a website in "Development Mode" ? (So that user will see a "Website is down for maintenance" message).

If "Website is down for maintenance" message is not possible, what other options are there to modify and test code in production?

# The next code line is currently commented out on purpose so it will be ignored.
# It is only for testing the code when you don't really want to close the site.
# It closes the site ONLY to you, but leaves it OPEN to everybody else.
# When commented out, the site is closed to everyone, including yourself.
# To enable the line, remove the # (pound sign) at the start of it.
# You MUST first change the digits 111 222 333 444 to match YOUR IP address.