• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Tuesday, July 24, 2012

STRING IN PHP


Hi… welcome again in my site in “We Are Knowledge”.

This site is site about IT knowledge… you can take many knowledge in here and you can getting learn in here.

Now, I want to giving you knowledge PHP about “STRING”. You know string in PHP. Define “string” is type of variable in PHP likely “integer, array, and other”.

Ih here I want giving you method, how to manipulation string ?.

Ok.. let’s reading my article..

COUNT THE NUMBER OF CHARACTER

You can copy this coding in your notepad

Example 1:

<?php
$a = "We Are Knowledge";
$b = strlen($a);
echo "number of character is : ", $b;
?>

Next, you must saving with “save as type = PHP”.

And result is :
number of character is : 16


COMPARING 2 (TWO) STRING)

You can copy this coding in your notepad

Example 2:

<?php
$a = "we are knowledge";
$b = "we are knowledge";
$c = strcmp($a, $b);
if ($c != 1)
{
echo "Your word is True";
}
else
{
echo "your word is false";
}
?>

Next, you must saving with “save as type = PHP”.

And result is :
Your word is True

Try you change “$b” be “$b = "we are ";”

And result is :
Your word is False


CAPITALIZE STRING

capitalize string is  command for making all letter be capital
You can copy this coding in your notepad

Example 3:

<?php
$a = "we are knowledge";
$b = strtoupper($a);
echo "before using strtoupper ", $a."<br>";
echo "after  using strtoupper ", $b;
?>

Next, you must saving with “save as type = PHP”.

And result is :

before using strtoupper we are knowledge
after using strtoupper WE ARE KNOWLEDGE


LOWERCASE

You can copy this coding in your notepad

<?php
$a = "WE ARE KNOWLEDGE";
$b = strtolower($a);
echo "before using strtolower ", $a."<br>";
echo "after  using strtolower ", $b;
?>

Next, you must saving with “save as type = PHP”.

And result is :

before using strtolower WE ARE KNOWLEDGE
after using strtolower we are knowledge


Ok.. just it…
I hope you understand with my tutorial…
Thanks for you..
See you later

No comments:

Post a Comment