PHP Loops | foreach

Hi everyone, This loop type is used with arrays. It goes through the end of an array and runs the loop for each array value. The syntax is : Here is an example about foreach loop: output will be :…

Read More

PHP Loops | for

Hi everyone, The for loop is used when you know in advance how many times the script should run. The syntax is: init: We use this mostly to set a counter (but can be any code to be executed once at…

Read More

PHP Loops | do..while

Hi everyone, do..while loop is executed at least once and if the condition in the end is true the code-block inside loop is executed. Here is the syntax: Here goes an example: output will be : This is the first…

Read More

PHP Loops | while

Hi everyone, Loops are code-blocks that are to be executed specified number of times, or while a specified condition is true. We often want to execute some code blocks several times. To do this, in PHP we have four types…

Read More

PHP Arrays

Hi everyone, An array is a variable that can hold multiple values inside itself. For example: If we want to declare two fruit variables like below it is OK. What if we want to hold all of the fruits. At…

Read More

PHP Switch

Hi everyone, We use the switch statement to select one of many blocks of code to be executed. In switch statement an expression is compared with some values for each case in the structure. If there is a match, the related…

Read More

PHP If..else

Hi everyone, Conditional Statement: The statements that helps us to perform different actions for different decisions. In real life; think about the example of toilets in public areas. According to your gender you choose either WC for men or WC…

Read More

PHP Operators

Hi everyone, The assignment operator = is used to assign values to variables in PHP. The arithmetic operator + is used to add values together. Operators can be groupped as: Arithmetic Operators Assignment Operators Incrementing/Decrementing Operators Comparison Operators Logical Operators…

Read More

PHP Strings

Hi everyone, A string variable is a type of variable in which we hold some characters. We can hold strings in a variable or we can directly use a string. Here is an example of using both methods. Both scripts…

Read More

PHP Variables

Hi everyone, Variables are some tags that we can give name to them and that gives us the possiblity to hold some values inside them. Variables also can hold some expressions as well. A PHP variable: can start with an…

Read More