formatting using PHP

So you’ve gone though some of the tutorial, and you can make some nifty things in PHP. But the problem is, they all look like plain text. How do you jazz them up?

Formatting with PHP actually isn’t done with PHP, it’s done with HTML. You can do this in two ways. You can add the HTML inside of the PHP… or you can add the PHP inside of the HTML. Either way, make sure your file is saved as a .php or another file type that is allowed to execute PHP on your server.

HTML inside PHP

<?php

echo “<font color=red>Premal Katigar</font>”;

?>

PHP inside HTML

<font color=”red”>

<?php echo “Premal Katigar”; ?>

</font>

Advertisements

Changing the capitalization of stings

Making the string all capital letters:

You can simulate the CAPSLOCK key using thestrtoupper() PHP function.

Making the string all lower case letters:

You can also force all letters in a string to be lower case. This is done with the strtolower() PHP function.

Capitalizing each word:

You can choose to only capitalize the first letter of every word. This works great when working with a list of names or cities. This is done with theucwords() PHP function.

Code :

<?php

// using strtoupper() we can easily get all characters in capital.

echo strtoupper(“This is Premal Katigar”);

?>
<br>
<?php

// using strtoupper() we can easily get all characters in capital.

echo strtolower(“This is Premal Katigar”);

// using ucwords() we can easily get all words with first character capitalized

?>
<br>
<?php
print((ucwords(‘premal,katigar’)));
?>

capitalize all words

Output Of above code :

capitalized character output

 

Know More about php

Mail me your topic or problems

premalkatigar2@gmail.com

Contact : +91-84604-57306