Getting Started: Node.js

This video tutorial illustrates, running node.js programs.

Video Contains

Download Nodejs
Downloading procedure.
Getting started with first node.js application(‘ Hello World ‘) program.

nodejs

hello.js

 console.log('Hello World');

This line, prints the string Hello World on the console window.

Command

Go to command prompt and navigate to the directory where you’ve saved hello.js file.
Now type the following command to execute the node.js program

 > node hello.js

i.e., node is the command followed by file name.

Video Tutorial: Hello World: Node.js


[youtube https://www.youtube.com/watch?v=eP6cUdIBwzM]

YouTube Link: https://www.youtube.com/watch?v=eP6cUdIBwzM [Watch the Video In Full Screen.]



Output:
Hello World

Note:
To let you know, I’m writing my code on Windows 7 Operating System. So please check with alternative methods for your operating system. If there’s any significant difference, do let us know in the comment section. Most of the code we write must work across various platforms.

Next Video..
This video tutorial is just to get you started with node.js
In our next video we’ll show you how to create a server using node.js and get the response from our server on to the web browser(upon request).

Stay tuned, it’s fun to explore it.

PHP Comments, String Concatenation, Addition of Numbers & Hello World

Today lets see these 4 basic things:
1. The classic “Hello World” program.
2. Comment system in PHP.
3. Concatenation of Strings.
4. Addition of Numbers.



Classic “Hello World” program
Program to output simple string

1
2
3
<?php
          echo "Hello World";
?>

Comments:

1
// This is single line comment
1
# This is also a single line comment
1
2
3
/* This is how multi-line comments
    are written.
*/

Anything following a double forward slash or a hash( # ) symbol will be ignored by your parser. Comments are very important and are often ignored by programmers. Comments come handy when we come back to the codes and want to make some changes to the coding. So its always a good practice to write comments wherever appropriate.

Concatenation of Strings
Concatination is joining of two or more strings end to end. Ex: if we concatenate Micro and soft, it will become Microsoft.
In PHP, we use .[DOT] operator for concatenation. Below is an example:

1
2
3
4
<?php 
         echo "Micro" . "soft";
         echo "<br />Oracle, " . "Sun Microsystems";
?>

The output for the above php code is:

1
2
Microsoft
Oracle, Sun Microsystems

Addition of Numbers
We can use variables for addition of numbers or we can simply make use of echo or print for addition of numbers.

1
2
3
<?php
         echo 10+20;
?>

This gives 30 as the output.

1
2
3
<?php
         echo "5"+10;
?>

This gives 15 as output. The string “5” will be implicitly converted into number and will be added to the actual number 10.