PHP Unit 2 PPT
PHP Unit 2 PPT
DU # 2302CS402
Unit-02
Functions and Form
<?php
function functionName()
{
//code to be
executed;
}
?>
Note: Function name can start with a letter or underscore "_", but not a number!
<?php <?php
function functionName() functionName();
{
//code to be function functionName()
executed; {
} //code to be
executed;
functionName(); }
?> ?>
// Example usage
echo factorial(5); // Output: 120
?>
Single quoted strings does not perform such actions, it returns the string like it
Output
was written, with the variable name:
Example
<?php
$x = "Good Morning";
echo 'Hello $x';
?>
#2302CS402 (PHP and WordPress) Unit 02 – Functions
Prof. Payal H Hinsu 23
String Functions
Section - 7
String Functions
String functions in PHP are built-in functions used to manipulate and
process strings.
PHP provides a wide range of these functions to perform various
operations, such as searching, replacing, formatting, and
analyzing strings.
String can be think as a array of characters, so it is possible to do
something like this,
$mystring = “Welcome to Darshan College of Engineering”;
print ($mystring[11]) ; // which will print ‘D’
This uses an index as an offset from the beginning of the string
starting at 0
Thank
You
Prof. Payal H Hinsu
Department of Computer
Engineering
Darshan Institute of Engineering & Technology for Diploma Studies, Rajkot
[email protected]
7096979963