Programming Lessons

[PHP]Let’s Display Letters![Programming for Kids and Above #2]

Hello, I’m kat, the manager of kat’s blog.

This article will be the second installment of the [Programming for Kids and Above] lecture series.

I explained about what programming is in my first article, so please check it if you haven’t seen it yet.

In the second installment, let’s go ahead and write out a program and display letters!

What we will use this time

The programming language we will use this time

This time we will use the following programming language to write out a program.

・PHP

PHP

Let’s go ahead and write out a program.

This time, we will be programming on a website called ‘paiza.’

First, let’s display the website by clicking the link below.

paiza website

Once the website is displayed, check to make sure that the button on the top left is showing as ‘PHP.’

If it hasn’t changed, choose ‘PHP.’

Once it is selected, please try writing the following in the source code area.

<?php

// Display letters
echo 'Hello World!';

After writing in the source code, click the ‘Run (Ctrl-Enter)’ button like the following image.

Then the result will be displayed.

If letters saying ‘Hello World!’ are displayed in the result area, it is a success.

Now allow me to give a brief explanation about the program.

~Explanation 1~

<?php

, means the start of a PHP program.

It is a rule to always put ‘<?php’ at the beginning of a PHP program.

~Explanation 2~

// Display letters

This is a comment to explain the content of the program.

If you put ‘//’ at the beginning, it will mean that it is a comment.

✓ Point

Even if you leave a comment, the process will not be changed.

If you write a comment, when others see the source code
they will be able to tell more easily what kind of processing has been applied.

~Explanation 3~

echo 'Hello World!';

This is a program that will display the letters, ‘Hello World!’

If you write the letters which you want to display after the letters ‘echo,’ the letters will be displayed on the screen.

The ‘;’ at the end, means the end of a process.

✓ Point

Character strings which have a certain process such as ‘echo,’ are called a ‘command’ or a ‘function.’

There are a large number of commands and functions when it comes to programming languages.

Because there are so many, it is impossible to remember all of them,
but I would like to explain the basic ones in this lecture series.

Final thoughts

We only covered simple programs which allow you to display things on the screen,
but I’m planning on writing about more interesting programs from next time, so please look forward to it.

See you next time!


ABOUT ME
kat
プログラマー歴7年、2歳の子供を持つパパです。 興味のあることはプログラミングや今後のIT技術などです。 趣味でオンラインカードゲームのサイトを運営しております。 プログラミングを通して社会に貢献していきたいです。