Built-in Functions
Explore commonly used PHP built-in functions.
Built-in Functions is a free PHP Academy lesson on CoddyKit — lesson 2 of 5. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the PHP Academy learning path, one of 5 lessons in the course, and your progress syncs across the web and the CoddyKit app.
1
Built-in Functions
Welcome to the next lesson! PHP provides a rich set of built-in functions to simplify common tasks like working with strings, arrays, dates, and more. In this lesson, you’ll learn how to use some of the most commonly used built-in functions. Let’s get started!

2
What Are Built-in Functions?
Built-in functions are predefined functions provided by PHP to perform specific operations. They save you time by handling complex tasks with just a function call.
Key Point: Built-in functions cover a wide range of areas, including string manipulation, mathematical calculations, and file handling.
3
String Functions
PHP provides functions to manipulate strings. Examples:
strlen(): Returns the length of a string.strtoupper(): Converts a string to uppercase.strtolower(): Converts a string to lowercase.
Example:
<?php
$string = "Hello, PHP!";
echo strlen($string); // Outputs: 11
echo strtoupper($string); // Outputs: HELLO, PHP!
?>
4
Array Functions
PHP provides functions to work with arrays. Examples:
array_push(): Adds elements to an array.array_pop(): Removes the last element of an array.in_array(): Checks if a value exists in an array.
Example:
<?php
$fruits = ["Apple", "Banana"];
array_push($fruits, "Cherry");
echo in_array("Cherry", $fruits); // Outputs: 1 (true)
?>
5
Date and Time Functions
PHP provides functions to work with dates and times. Examples:
date(): Formats a timestamp.time(): Returns the current timestamp.
Example:
<?php
echo date("Y-m-d");
// Outputs: Current date (e.g., 2024-12-29)
echo time();
// Outputs: Current timestamp
?>
6
Mathematical Functions
PHP provides functions for mathematical operations. Examples:
abs(): Returns the absolute value.round(): Rounds a number to the nearest integer.sqrt(): Returns the square root of a number.
Example:
<?php
echo abs(-10); // Outputs: 10
echo round(3.6); // Outputs: 4
echo sqrt(16); // Outputs: 4
?>
7
Working with Files
PHP provides functions to handle files. Examples:
file_get_contents(): Reads a file into a string.file_put_contents(): Writes a string to a file.unlink(): Deletes a file.
Example:
<?php
$filename = "example.txt";
file_put_contents($filename, "Hello, PHP!");
echo file_get_contents($filename); // Outputs: Hello, PHP!
?>
8
Using Function Documentation
PHP provides detailed documentation for all its built-in functions. Visit PHP.net to explore the full list of functions.
Tip: Always check the documentation for examples and edge cases.
9
10
Great Job!
Congratulations! You’ve learned how to use PHP’s built-in functions for strings, arrays, dates, and more. These functions save time and simplify your code. In the next lesson, you’ll learn how to create your own functions in PHP. Let’s keep coding!

Frequently asked questions
Is the “Built-in Functions” lesson free?
Yes — the full text of “Built-in Functions” is free to read here on the web, and the PHP Academy course includes 5 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the PHP Academy course, upgrade to CoddyKit PRO.
What will I learn in “Built-in Functions”?
Explore commonly used PHP built-in functions. You practise PHP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start PHP Academy?
No prior experience is required. PHP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 5, so you can start here or from the beginning and move at your own pace.
How long does the “Built-in Functions” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this PHP Academy lesson?
Yes. Every PHP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.