If you are attending classes in any PHP training institute then there are few concepts that you must learn in detail. Some of the most important concepts are mentioned are mentioned in this blog which are very useful and important to learn for a beginner.
Let’s discuss each concept one by one.
Advance Functions in PHP
Before learning advance functions you should know about what is function in PHP. A Function is a set of code which executes every time it called.
But as we know there are more than 1000 Built-In functions in PHP. Some of them i have learned in my last class:
- Func_num_args() : Func_num_args return the number of arguments paassed in that function. In short it tells about length of passed arguments.
- Func_get_arg() : This function returns the number of argument with their Index value. Can say that it is simialar to the print_r function.
- Func_get_args() : Func_get_args returns an array comprising a function's argument list. It works similar to the var_dump printing function.
Note: Dont use echo to print an array. It will throw an error always that is "Array to string conversion ".
Loops in PHP
There are four types of loops, I have learned about in PHP
- for each : foreach loop used to print each value of an array. It works only with array. Prints value with key and value pair.
Output :
red
green
blue
yellow
- for: for loop executes only specified number of times. It is mostly similar to for loop in JavaScript but only one difference is that, Use count instead of length. And there are three phases of code execution such as Initialization, Condition, and increment.
- While: While loop executes as long as specified condition is true. When the condition become false while loop stops execution.
- Do while: This is similar to the while loop. But it is executed at least once whether the giver condition is true or false.
Next concept which you need to learn during your classes in PHP training institute in Delhi is Switch case.
Switch case
Switch case is basically used to check different conditions. And executes a set of code depending on which condition is true or equal to that value. It is similar to if else in many cases but In switch case we can use break.
Let’s see an example to understand the syntax of switch case
$color = "pink";
switch ($color) {
case "red":
echo "Your favorite color is red!";
break;
case "pink":
echo "Your favorite color is pink!";
break;
default:
echo "Your favorite color is neither red nor pink!";
}
?>
In this example here is a variable i.e. $color and its value is "pink". After that here is switch case it will check cases one by one and where the condition will become true it will break the code and left other code unread. It helps in improving speed.
So, this is all about some important concepts that you need to learn during your PHP course from a good web development institute in Delhi.