Home | | Computer Application 12th Std | String Functions in PHP

Practical Experiments | Computer Applications - String Functions in PHP | 12th Computer Applications : Practical Experiments

Chapter: 12th Computer Applications : Practical Experiments

String Functions in PHP

To create and execute String Functions in PHP

String Functions

 

AIM

To create and execute String Functions in PHP

 

Procedure

1. Start Xampp server (Apache)

2. Goto virtual path folder (C:\xampp\htdocs)

3. Create funtion.php file and type the program

4. Execute the program on your Web browser using by this URL link

 

(http://localhost/ funtion.php)

<html>

<body>

<?php

//Displays the length of the string

echostrlen(“Hello world!”);

//Counting number of words in a String

echo str_word_count(“Good Morning All”);

//Reversing a string

echo strrev(“welcome”);

// calculates position of strong

echo strpos(“Hello world!”, “world”);

// replacing the text

echo str_replace(“Hi”, “Hello”, “Hi Everyone”);

define(“GREETING”, “Good Morning!!!”);

echo GREETING;

//changes the color of the first character of a word

$text = ‘PHP Tutorial’;

$text = preg_replace(‘/(\b[a-z])/i’,’<span style=”color:red;”>\1</span>’,$text);

echo $text;

?>

</body>

</html>

 

OUTPUT

12

3

emoclew

6

Hello Everyone

Good Morning!!!

PHP Tutorial

Tags : Practical Experiments | Computer Applications , 12th Computer Applications : Practical Experiments
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Applications : Practical Experiments : String Functions in PHP | Practical Experiments | Computer Applications


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.