Instruction
1
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
2
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