I’m kat, the manager of ‘kat’s blog.’
This time, which is the sixth installment of the ‘Programming Lessons’ series, I will be talking about handling letters and variables.
Up until last time, programming-wise we’ve been going over putting letters into variables.
However, for letters and variables, it is also possible to connect more letters and variables in the middle.
Let’s learn about how to do that this time!
What we will use this time
This time we will use the following programming language to write out a program.
Let’s use the paiza website which is listed below for executing the program.
For those who are using this website for the first time, the way to use it is listed in the page below, so please check it out.
Let’s connect letters with letters
Without further ado, allow me to explain how to connect letters with letters.
Write out the source code as shown below, and execute it.
<?php $message = "Hello." . "Mr.Bobby."; echo $message;
Then the result will show up as follows.
$message = "Hello." . "Mr.Bobby.";
The letters have been connected, and been put into an array.
You can tell that there is a ‘. (dot)‘ between “Hello.” and “Mr.Bobby.”
Actually for PHP, you can connect letters simply by putting this ‘. (dot)’ in between.
The letters that have been connected are displayed.
Here, ‘Hello.’ and ‘Mr.Bobby.’ are connected and
will be displayed.
When you connect letters with letters, a ‘. (dot)’ is used.
Let’s connect letters with variables
Earlier we connected letters with letters, but let’s connect letters with variables this time.
First, let’s take a look at the source code.
<?php $name = "Mr."; $message = "Hello.". $name . "Bobby." ; echo $message;
Once executed, the result will also be as the following.
$name = "Mr."; $message = "Hello." . $name . "Bobby." ;
First, in the ‘$name’ variable, the title ‘Mr.’ is entered.
And in the next row, ‘Hello.’ and ‘$name’ and ‘Bobby.’ are connected by a ‘. (dot)’.
As you probably know already, just like when you connect letters with letters, you also use a ‘. (dot)’ when you connect letters with variables.
For this time ‘Bobby’ is in ‘$name,’ so the execution result will be all of them put together and it will be,
will be displayed.
Even when connecting letters with variables, and variables with variables , a ‘. (dot)’ is used.
Thank you for reading to the end of this lesson this time as well.
This time we learned how to connect letters with letters, and letters with variables.
The process of connecting letters and variables is used often when doing loop processing, so let’s make sure to remember it.
We will start learning about loop processing from the next article, so please look forward to it!
See you next time!