Functions Functions

YouTip LogoYouTip

PHP Tutorial - Getting Started

PHP Basics

<?php
$name = "Alice";
$age = 25;
echo "Hello, $name!";

$arr = ["apple", "banana", "cherry"];
foreach ($arr as $item) {
    echo $item;
}
?>

Functions

<?php
function greet(string $name): string {
    return "Hello, $name!";
}
echo greet("World");
?>

Summary

  • PHP code goes in <?php tags
  • Variables start with $
← Ruby Tutorial - Getting StarteFastAPI Tutorial - Getting Sta β†’