# PHP Basics Cheat Sheet
### by Sikho Programming — sikho_programming on Instagram

## Syntax
```php
<?php
  $name = "Sikho";
  echo "Hello, " . $name;
?>
```

## Variables
Always start with `$`. No type declaration needed.
```php
$name = "Sikho";
$followers = 2750;
$rating = 4.8;
$isLive = true;
```

## Data Types
| Type | Example |
|---|---|
| string | `"hello"` |
| integer | `5` |
| float | `5.0` |
| boolean | `true` / `false` |
| array | `["PHP", "Python"]` |

## echo vs print
```php
echo "Hello";                 // no return value, slightly faster
echo "Hello", " ", "World";   // can take multiple arguments
print "Hello";                 // always returns 1, one argument only
```
Rule of thumb: use `echo` by default.

## Comments
```php
// single-line
# also single-line
/* multi
   line */
```

## Conditionals
```php
if ($followers > 1000) {
    echo "Growing!";
} else {
    echo "Keep posting.";
}
```

## Loops
```php
for ($i = 0; $i < 3; $i++) {
    echo $i;
}

foreach ($languages as $lang) {
    echo $lang;
}
```

## Arrays
```php
$langs = ["PHP", "Python"];
$langs[] = "C";          // append
echo $langs[0];          // access
echo count($langs);      // length
```

## Common Errors to Watch For
- Forgetting the `$` before variable names
- Missing semicolons at the end of statements
- Mixing up `=` (assignment) and `==` (comparison)

---
More tutorials at sikho_programming on Instagram, and on our website's Tutorials page.
