Topic: PHP Basics – Part 2 of 10: Data Types and Operators
---
1. PHP Data Types
PHP supports multiple data types. The most common include:
• String – A sequence of characters.
• Integer – Whole numbers.
• Float (Double) – Decimal numbers.
• Boolean –
• Array – Collection of values.
• Object, NULL, Resource – Used in advanced scenarios.
---
2. Type Checking Functions
---
3. PHP Operators
• Arithmetic Operators
• Assignment Operators
• Comparison Operators
• Logical Operators
---
4. String Concatenation
• Use the dot (
---
5. Summary
• PHP supports multiple data types and a wide variety of operators.
• You can check and manipulate data types easily using built-in functions.
---
Exercise
• Create two variables: one string and one number. Perform arithmetic and string concatenation, and print the results.
---
#PHP #DataTypes #Operators #Backend #PHPTutorial
https://t.iss.one/Ebooks2023
---
1. PHP Data Types
PHP supports multiple data types. The most common include:
• String – A sequence of characters.
$name = "Ali";
• Integer – Whole numbers.
$age = 30;
• Float (Double) – Decimal numbers.
$price = 19.99;
• Boolean –
true or false.$is_active = true;
• Array – Collection of values.
$colors = array("red", "green", "blue");• Object, NULL, Resource – Used in advanced scenarios.
---
2. Type Checking Functions
var_dump($variable); // Displays type and value
is_string($name); // Returns true if $name is a string
is_array($colors); // Returns true if $colors is an array
---
3. PHP Operators
• Arithmetic Operators
$a = 10;
$b = 3;
echo $a + $b; // Addition
echo $a - $b; // Subtraction
echo $a * $b; // Multiplication
echo $a / $b; // Division
echo $a % $b; // Modulus
• Assignment Operators
$x = 5;
$x += 3; // same as $x = $x + 3
• Comparison Operators
$a == $b // Equal
$a === $b // Identical (value + type)
$a != $b // Not equal
$a > $b // Greater than
• Logical Operators
($a > 0 && $b > 0) // AND
($a > 0 || $b > 0) // OR
!$a // NOT
---
4. String Concatenation
• Use the dot (
.) operator to join strings.$first = "Hello";
$second = "World";
echo $first . " " . $second;
---
5. Summary
• PHP supports multiple data types and a wide variety of operators.
• You can check and manipulate data types easily using built-in functions.
---
Exercise
• Create two variables: one string and one number. Perform arithmetic and string concatenation, and print the results.
---
#PHP #DataTypes #Operators #Backend #PHPTutorial
https://t.iss.one/Ebooks2023
❤2🔥1