PHP/String/strtoupper

Материал из Web эксперт
Перейти к: навигация, поиск

Changing case of strings

 
<?
print strtoupper("i"m not yelling!");
print strtolower("<A HREF="one.php">one</A>");
?>



Converting Case

 
<?php
$membership = "mz00xyz";
$membership = strtoupper( $membership );
print "$membership<P>"; // prints "MZ00XYZ"
?>



Modifying capitalize( ) to take a reference parameter

 
<?php
function capitalize( &$str, $each=TRUE ){
{   
   $str = strtolower($str);
   if ($each === true) {
      $str = ucwords($str);
   } else {
      $str{0} = strtoupper($str{0});
   }
}
$str = "hEllo WoRld!";
capitalize( $str );
echo $str;
?>



string strtoupper ( string str ) returns that string entirely in uppercase characters.

 
<?
    $string = "I like to program in PHP";
    $a = strtoupper($string);
?>



strtoupper(): Convert a string to uppercase

 
its syntax is: string strtoupper (string string)
<?
$sentence = "cooking";
$sentence = strtoupper($sentence);
print $sentence;
?>



strtoupper.php

 
<?php
   $msg = "text.";
   echo strtoupper($msg);
?>



Using the word case functions

 
<?php
$username="John Bond";
echo("$username in uppercase is ".strtoupper($username).".<br />");
echo("$username in lowercase is ".strtolower($username).".<br />");
echo("$username in first letter uppercase is ".ucwords($username).".<br />");
?>