Thomas Venturini
Hello World!

Hello World!

This is the first article on this my new blog. So I will cover some Hello World! examples for PHP and Python3. Enjoy!

Traditionally the first example anyone makes in a new programming language is the popular Hello World! example. So I thought to my self: "let's do some of these in my first article". So let's get to it!

The Goal

In a Hello World! example you simply want to print out Hello World!. Thats it!

Preparation - Vagrant

If you are not on a Debian based Linux system then you might want to use Vagrant, which is a nice and simple way to get a predefined virtual server up and running. I am only going to show installation instructions for Debian based Linux systems.

If you have Vagrant installed you can use the following commands to setup your virtual server and start playing around.

cd path/to/working/directory
vagrant init ubuntu/xenial64
vagrant up
vagrant ssh

Thats it. Three little commands and you have a running ubuntu/xenial64 virtual server running. By running vagrant ssh we login to the virtual server. That should do the trick.

PHP

PHP was the first programming language I learned. So it feels normal to do this one first. If you don't have PHP installed already go to php.net and read the installation instructions for your OS.

On ubuntu you can run the following command from a terminal to install PHP.

sudo apt-get install php -y

Now you can use the php command in your terminal to run your our first "Hello World!" example.

php -r "echo 'Hello World!';"

This should print the following line on your terminal.

Hello World!%

You did it! This was your first example. But we can go further. Open up a new file, with a .php file ending and puth the following code into it.

<?php

echo "Hello World!";

Now run your first PHP programm with the following command from your terminal.

php example.php

This also should print out Hello World! on your terminal.

Python

I am currently learning python so let's do this one to. If you don't have python installed already go to python.org and follow the installation instructions.

On ubuntu you can run the following command from a terminal to install python.

sudo apt-get install python3 -y

Now you can enter the interactive python mode from a terminal by typing in python. Go ahead and enter the following code.

print("Hello World!")

This to should print out Hello World!. Yey!

Let's go further! Open a new file with the file ending .py and enter the following code.

#!/usr/bin/env python

print("Hello World!")

Now run your first python programm with the following command from your terminal.

python example.py

You can guess what this one should print out right? Yes, Hello World!.

Conclusion

You did it! You just learned two programming languages ... some how 😉

As you can see, on my blog you will find a lot about PHP, Python, Linux/Ubuntu and everything else you can use as a webdeveloper. If you like my content, follow me on twitter so you never miss a post or tweet.