0% found this document useful (0 votes)
4 views

php.5

The document contains PHP code snippets for various string and mathematical operations. It demonstrates how to calculate the length of a string, count the number of words in a string without using string functions, and utilize PHP math functions like absolute value, square root, maximum, minimum, floor value, and power function. Each code snippet is accompanied by its expected output.

Uploaded by

Prasad Pangarkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

php.5

The document contains PHP code snippets for various string and mathematical operations. It demonstrates how to calculate the length of a string, count the number of words in a string without using string functions, and utilize PHP math functions like absolute value, square root, maximum, minimum, floor value, and power function. Each code snippet is accompanied by its expected output.

Uploaded by

Prasad Pangarkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Write a program to calculate length of string.

<html>
<body>
<?php
$word="Gauri";
echo"<br>string is :=> $word</br>";
echo"<br>length of words:=>".strlen($word)."</br>";
?>
</body>
</html>

OUTPUT:
Write a program to count number of words in string without using string function.

<?php
function word($string)
{
return count(explode(" ", trim($string)));
}
$mystr = "I am Gauri";
$mylen = word($mystr);
echo "</br>Given string: " . $mystr;
echo "</br>Number of words in string: " . $mylen;
?>

OUTPUT:
Write a program to demonstrate PHP maths function.

<?php
echo"Absoulte Values:=>".abs(-10)."<br>";
echo"Square Root:=>".sqrt(8)."<br>";
echo"Maximum number:=>".max(10,20,30)."<br>";
echo"Minimum Number:=>".min(10,20,30)."<br>";
echo"Floor Value:=>".floor(3.10)."<br>";
echo"Power Function:=>".pow(2,3)."<br>";
?>

OUTPUT:

You might also like