Advice 1: How to do a script

Literally translated, the word script means the script that is the description of the sequence of actions which need to be made to perform a specific task. In relation to Internet programming such tasks can be, for example, the clock displaying on the web page, the implementation of a variety of visual effects with pictures etc showing in the browser page itself in a modern network is also running on the specified in the script scenario. Let's try to write a few simple scripts to get an idea of what they represent.
How to write scripts
Depending on where the execution of the script, the scripts are divided into "client" and "server". If some address in the network, we send the URL of pages to the server and that runs the script located at the specified address. The script executing on the server programmed in this operation, collects the page from the right blocks and send it to the browser. It is the server side script. After receiving the page, the browser on our computer renders it for us and if in the resulting page code is a script, then he deals with the execution of this script. This is a client script.
To server or browser to be able to read, understand and execute the script it needs to be made and recorded according to the known rules. Such rule sets are called scripting programming languages. Most server-side scripts are currently written in PHP, and most of the client - in JavaScript. To write a script enough to have a plain text editor – Notepad. But for a permanent programming of scripts to do without a specialized editor. This editor takes the lion's share of routine work on writing scripts, leaving the programmer more time for creativity.
Let's write a simple script on the server PHP. The first line is necessary to inform the contractor that this place begins the script. In PHP this opening tag looks like this:<?RRA closing tag:?>Between these two tags are the user - language operators. For example, an instruction to print a sign, left O. Bender on the Caucasian cliffs, is written like this:echo ("there was kisya and Osya");And the instruction to show the current time in the format HOUR:MINUTE written as:echo date('H:i');All PHP script is composed of these operators will look like this:<?phpecho ("In ");
echo date('H:i');
echo (" there was kisya and Osya!");?>After executing this script, the server program-performer (interpreter) page would look like this:
The result of executing the server script
But the same script on the client JavaScript would be:var now = new date();
document.write ("");
document.write (now.getHours() + ":" + now.getMinutes());
document.write (" there was kisya and Osya!");Here, the string var now = new date() gives the contractor the script command to create a new virtual object named "now" which represents the current date and time. document.write () is the command to write in the page that is indicated in parentheses, and the team now.getHours() now.getMinutes() prescribe to fetch from the object “now” the current hour and minute.
Left for greater clarity, to combine these two script into a single file, save it on the server and type in the URL in the browser address bar. The result will see the same rows, one of which was implemented in our scenario on the server (with PHP interpreter) and the other in our computer (the JavaScript interpreter).
The result of executing the client and server scripts

Advice 2: How to make a script

In Internet programming, there is always a need to draw a virtual contractor to perform the needed programmer actions in the browser or on the server. Actions can be, for example, visual effects or processing of the entered visitor data in your browser. Or build the requested page from the individual blocks on the server. Virtual by these actions will be the server software or browser, and the script for the performer will have to write on one of the scripting programming languages. To get a General idea about how to make scripts, let's write a simple script in JavaScript.
How to make a script
JavaScript runs within your browser, so all that is needed for writing and execution, is already in the computer. As a working tool of the programmer will use a plain text editor - Windows Notepad. This is enough to create a simple script, but, of course, for permanent programming it is better to use a specialized editor.The first step: in Notepad, create a new document to record the instructions to the browser.
Now you can start writing code instructions. The browser understands more than one language - for example, for the page markup language is HTML (HyperText Markup Language "hypertext markup language"), and to further describe the appearance of page elements - CSS (Cascading Style Sheets - "cascading style sheets"). To give the executor of the script to understand that this part of the source page is written in JavaScript, all instructions should be placed inside opening and closing tags:<script type="text/javascript">
</script>Instructions for the browser are called by the operators of the language. For example, the instruction to read and memorize for use later in the script the current date and time of the computer looks like this:var aTime = new Date();Now the object contains data aTime on the date and time and, if necessary, they can be retrieved and processed. Other manual - printed in the page body or a message looks like this:document.write("any message");note - there is an object named "document", it is not necessary to create, this happens automatically. It is a virtual image of the current page. From this object you can retrieve information about the page and can implement different transformation - for example, in this line of code you write is recorded in the document the text "some message".Now engage in the scenario of both these lines - write on the page current time:document.write ("the Current time" + aTime.getHours() + ":" + aTime.getMinutes());Here a simple operation of addition (+) you held up four constituent parts of the print string. The final your simple script would look like this:<script type="text/javascript">
var aTime = new Date();
document.write ("the Current time" + aTime.getHours() + ":" + aTime.getMinutes());
Final step: save the script with file extension html or htm (for example, timeJS.html). To see what you got, open the file in browser, just click it double click.
Is the advice useful?