- XAMPP
- PHP development environment
- Console Panel
C:\xampp\htdocs
=> Make projects inside this path
- Basic
- Print
<?php
echo "Namaste Dunia!"; // Prints the string value given
echo "<br>"; // Executes the HTML
echo $varName; // Prints the value of the variable
echo $varName[N]; // Prints element in an array
?>
- Conditional Statements
<?php
if (condition1) {
// Statements
} else if (condition2) {
// Statements
} else {
// Statements
}
?>
- Loops
<?php
for ($a = N1; $a < N2; $a++) {
// Statements
}
foreach ($varName as $value) {
// Statements
}
while (condition) {
// Statements
}
do {
// Statements
} while (condition);
?>
- Array
count($varName)
=> Returns total number of elements
- String
$varName."value"
=> String concatenation
strlen($varName)
=> Returns length of string
str_word_count($varName)
=> Returns number of words in string
strrev($varName)
=> Returns reversed string
strpos($varName, "value")
=> Returns the position of the value in string
str_replace("value1", "value2", $varName)
=> Returns the string with replaced value
- Function
function varName(arguments) {
// Statements
}
varName(parameters);