The else statement as a concept is very easy to understand and straight forward. This statement is used in combination with the IF statement and what it does is extending the if statement. You use “else” when you want to run a piece of code when the condition of the “if” is not met.
php
IF statement
By now you should have figured that variables are just some “places” in which we store information, but what do we do with that information? I mean we need to do something with it and not just output it to the screen with the help of the browser and one of the most important thing we need to do with them is deciding what to do next if a condition is met like for example if x = 10, do something and that is a thing called conditional logic and by
Adding / Small exercise
Now that you learned how to declare variables and concatenate them let’s make a simple exercise and use what we learned in the last tutorials to generate a message that the server will output to the browser:
Concatenation
The process of concatenation consists of joining two or more variables separating them with a dot. Suppose you want to echo out the following “My age is 25”, you can do it this way:
<?php
$text = “My age is”;
$age = 25;
Variables in php
Hello again, today i decided to write some basic concepts about php as a programming language and the first thing i want to talk about are the variables.
First thing that you should know is that when you declare a variable you need to put the dollar ( $ ) sign before your variable ex: $x;
List of IDEs and free text editors
As i promised i have made a list with some of the IDEs that i think they are good:
Free text editors:
Your first php script
Now that you installed xampp it’s time to set up your project and write your very first php script.
First go to the server root path ( if you remember from the installing and setting up xampp post ) and inside it create a new folder, i will name it “tryphp”. Be careful with that name because it will be important in the future, i recommend to not use spaces or any kind of special characters
Installing and setting up Xampp for windows
First of all in order to use php you need a package like xampp/wamp on your computer in order to create a localhost server. I will personally choose xampp because i worked a lot more with it and i like it more but it’s just a personal choice so feel free to choose your own piece of software if you feel so.